#include <stdio.h>
//输入年龄 20
//your age is twenty;
int main(){
int age = 0;
//保存个位数 21%10 = 1
char* gewei[] = {"","one","two","three","four","five","six","seven","eight","nine"};
//保存10-19
char* temp[] = {"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
//保存十位
char* shiwei[] = {"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
printf("请输入年龄:");
scanf("%d", &age);
char *name;//保存每次取出的字符串
if(age < 10){
//直接访问各位数数组
name = gewei[age];
}else if(age >= 10 && age <= 19){
//获取个位数
int index = age % 10;
name = temp[index];
} else{
//获取个位数
int g = age % 10;
//获取十位数
int s = age / 10;
//取出对应的单词
int sString = shiwei[s-2];
int gString = gewei[g];
printf("your age is %s-%s\n"
,sString,gString);
//程序还未运行完毕就提前结束
return 0;
}
printf("your age is %s\n",name);
return 0;
}
一个翻译小程序
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Coding Java the java filename should be the same as the n...
- :first-of-type 表示一组兄弟元素中其类型的第一个元素 html部分: css .ct02 p:f...