C语言编程:输入一个小于100的整数,输出相应的英文单词。
发布网友
发布时间:2024-10-13 17:30
我来回答
共1个回答
热心网友
时间:2024-10-13 17:32
#include"stdio.h"
#include"math.h"
unsigned char Number[][10]={
"zero","one","two","three","four","five","six","seven","eight","nine",
"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
unsigned char Tens[][10]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"};
void deal(int n)
{
if(n<20)
{
printf("%s\n",&Number[n][0]);
}
else
{
printf("%s ",&Tens[n/10-2][0]);
if(n%10)
printf("%s\n",&Number[n%10][0]);
else
printf("\n");
}
}
void main()
{
int n;
scanf("%d",&n);
if(n>=100)
printf("数据过大");
else
deal(n);
}
单词不知道会不会有敲错的,稍微自行检查下哦