# 请帮忙找找错误，谢谢

2301_80439625 2023-11-19 20:32:02

#include<stdio.h>

int main(){

int x;

scanf("%d",&x);

if(x==0) printf("zero");

if(x>0&&x<1000){

char*a[19]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thriteen","forteen","fifteen","sixteen","seventeen","eighty","nineteen"};

char*b[8]={"twenty","thrity","forty","fifty","sixty","seventy","eighty","ninety"};

if(x/100!=0){ printf("%s",a[(x/100-1)]);

printf(" hundred");

if(x%100<20) printf(" and %s",a[(x%100-1)]) ;

if(x%100>=20) printf(" and %s-%s",b[(x%100/10-2)],a[(x%100%10-1)]);}

if(x/100==0){

if(x<20) printf("%s",a[(x-1)]);

if(x>=20) printf("%s-%s",b[(x%10-2)],a[(x%10%10-1)]);

}}

if(x>=1000||x<0) printf("ERR");}

...全文
111 2 打赏 收藏 转发到动态 举报

2 条回复

• 打赏
• 举报

#include<stdio.h>
void main()
{
char *Eng1[20]={"zero","one","two","three","four","five","six","seven",
"eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen",
"sixteen","seventeen","eighteen","nineteen"};
char *Eng2[8]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"};
int num;
printf("请输入数字: ");
scanf("%d",&num);
printf("对应的英文为: ");
if(num>=0&&num<=19)
printf("%s\n",Eng1[num]);
else if(num<100)
{
int s,y;
s=num/10;
y=num%10;
printf("%s %s\n",Eng2[s-2],Eng1[y]);
}
else if(num<1000)
{
int b,s,y;
b=num/100;
y=num%100;
if(y>9)
{
s=(num%100)/10;
y=(num%100)%10;
if(y==0)
printf("%s hundred and %s\n",Eng1[b],Eng2[s-2]);
else
printf("%s hundred and %s %s\n",Eng1[b],Eng2[s-2],Eng1[y]);
}
else
printf("%s hundred and %s\n",Eng1[b],Eng1[y]);
}
}

• 打赏
• 举报

#include <stdio.h>

int main() {
int x;

``````scanf("%d", &x);

if (x < 0 || x >= 1000) {
printf("ERR");
} else if (x == 0) {
printf("zero");
} else {
char *a[19] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven",
"twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
char *b[8] = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};

if (x / 100 != 0) {
printf("%s hundred", a[x / 100 - 1]);

if (x % 100 != 0) {
printf(" and ");

if (x % 100 < 20) {
printf("%s", a[x % 100 - 1]);
} else {
printf("%s-%s", b[x % 100 / 10 - 2], a[x % 100 % 10 - 1]);
}
}
} else {
if (x < 20) {
printf("%s", a[x - 1]);
} else {
printf("%s-%s", b[x / 10 - 2], a[x % 10 - 1]);
}
}
}

return 0;
``````

}

69,112

• 近7日
• 近30日
• 至今