0
#include<stdio.h>
int main(){
int numero,unidade,dezena,centena;
char *unidades[]={"I","II","III","IV","V","VI","VII","VIII","IX"};
char *dezenas[]={"X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
char *centenas[]={"C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
scanf("%d",&numero);
unidade=(numero%100)%10;
dezena=(numero%100)/10;
centena=numero/100;
if (centena){
printf("%s",centena[centena-1]);
}
if (dezena){
printf("%s",dezena[dezena-1]);
}
if (unidade){
printf("%s",unidade[unidade-1]);
}
printf("\n");
return 0;
}
So, I was trying to make the 1960 URI, which consists of converting a decimal number to a number in Roman numerals, but I’m having trouble printing the string.
The following error occurs:
subscripted value is neither array nor Pointer nor vector printf("%s",hundred[hundred-1]);
The same occurs for dozens and units.
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero