这两个c语言程序设计题目有点懵,哪个大佬来帮一下,感谢
2020-04-22
#include <stdio.h>
int main(void) {
char *a[] = {"ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
};
char *b[] = {"twenty", "thirty", "forty", "fifty",
"sixty", "seventy", "eighty", "ninty"};
char *c[] = {"one", "two", "three", "four", "five",
"six", "seven", "eight", "nine"};
int num;
scanf("%d", &num);
switch(num<20){
case 0:
if(num%10!=0)
printf("%s %s\n",b[num/10-2],c[num%10-1]);
else
printf("%s\n",b[num/10-2]);
break;
case 1:
printf("%s\n",a[num-10]);
break;
}
return 0;
}
2020-04-22
int main()
{
int a;
int g,s; //g个位数,s十位数
printf("请输入一个两位数的整数\n");
scanf("%d",&a);
g=a%10;
s=a/10;
if(s==1)
{
switch(g)
{
case 0:printf("ten");break;
case 1:printf("eleven");break;
case 2:printf("tweleve");break;
case 3:printf("thirteen");break;
case 4:printf("fourteen");break;
case 5:printf("fifteen");break;
case 6:printf("sixteen");break;
case 7:printf("seventeen");break;
case 8:printf("eigtheen");break;
case 9:printf("nineteen");break;
}
}
else
{
switch(s)
{
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("eigthty ");break;
case 9:printf("ninety ");break;
}
switch(g)
{
case 1:printf("one\n");break;
case 2:printf("two\n");break;
case 3:printf("three\n");break;
case 4:printf("four\n");break;
case 5:printf("five\n");break;
case 6:printf("six\n");break;
case 7:printf("seven\n");break;
case 8:printf("eigth\n");break;
case 9:printf("nine\n");break;
}
}
return 0;
}
#include
int main()
{
int a;
int g,s; //g个位数,s十位数
printf("请输入一个两位数的整数\n");
scanf("%d",&a);
g=a%10;
s=a/10;
if(s==1)
{
switch(g)
{
case 0:printf("ten");break;
case 1:printf("eleven");break;
case 2:printf("tweleve");break;
case 3:printf("thirteen");break;
case 4:printf("fourteen");break;
case 5:printf("fifteen");break;
case 6:printf("sixteen");break;
case 7:printf("seventeen");break;
case 8:printf("eigtheen");break;
case 9:printf("nineteen");break;
}
}
else
{
switch(s)
{
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("eigthty ");break;
case 9:printf("ninety ");break;
}
switch(g)
{
case 1:printf("one\n");break;
case 2:printf("two\n");break;
case 3:printf("three\n");break;
case 4:printf("four\n");break;
case 5:printf("five\n");break;
case 6:printf("six\n");break;
case 7:printf("seven\n");break;
case 8:printf("eigth\n");break;
case 9:printf("nine\n");break;
}
}
return 0;
}