你的目的是什么?是不是将输入的二位数转换为对应的英文?如果是,你可以参考下面的代码:
#include
int main(void)
{
int n,n1,n2;
printf("Enter a two-digit number: ");
scanf("%d",&n);
printf("You entered the number:");
//判断输入是否正确
if(( n 99)){
printf("请你输入一个两位数!\n");
return 0;
}
if(n <= 20){
switch(n){
case 10: printf("ten"); break;
case 11: printf("eleven"); break;
case 12: printf("twelve"); break;
case 13: printf("thirteen"); break;
case 14: printf("fourteen"); break;
case 15: printf("fifteen"); break;
case 16: printf("sixteen "); break;
case 17: printf("seventeen "); break;
case 18: printf("eighteen "); break;
case 19: printf("ninteen "); break;
case 20: printf("twenty "); break;
}
}else{
n1=n/10;n2=n%10;
switch (n1) {
case 2: printf("twenty"); break;
case 3: printf("thirty"); break;
case 4: printf("forty"); break;
case 5: printf("fifty"); break;
case 6: printf("sixty"); break;
case 7: printf("seventy"); break;
case 8: printf("eighty"); break;
case 9: printf("ninty"); break;
}
if( n2 != 0){
//判断是不是需要输出-
printf("-");
}
switch (n2) {
case 1: printf("one"); break;
case 2: printf("two"); break;
case 3: printf("three"); break;
case 4: printf("four"); break;
case 5: printf("five"); break;
case 6: printf("six"); break;
case 7: printf("seven"); break;
case 8: printf("eight"); break;
case 9: printf("nine"); break;
}
}
} 。
全部