这两个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
展开全部
#include<stdio.h>
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;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式