P53 第36题 数字转化成英语输出

#include <stdio.h>
  int main()
  {
   int a,b,c,d;
   while(1)
   {
   printf("请输入一个三位整数\n");
   scanf("%d",&a);
   b=a%10;
   c=a/10%10;
   d=a/100;
   switch(d)
   {
   case 1:printf("one hundred ");break;
      case 2:printf("two hundred ");break;
   case 3:printf("three hundred ");break;
      case 4:printf("four hundred ");break;
   case 5:printf("five hundred ");break;
      case 6:printf("six hundred ");break;
   case 7:printf("seven hundred ");break;
      case 8:printf("eight hundred ");break;
   case 9:printf("nine hundred ");break;
   }
   if(b==0&&c==0)
    printf(" ");
   else
    printf("and ");
   if(c!=1)
   {
   switch(c)
   {
      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("eighty ");break;
   case 9:printf("ninety ");break;
      case 0:printf(" ");break;
   }
   switch(b)
   {
   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("eight\n");break;
   case 9:printf("nine\n");break;
      case 0:printf(" \n");break;
   }
   }
   if(c==1)
   {
   switch(b)
   {
   case 1:printf("eleven\n");break;
      case 2:printf("twelve\n");break;
   case 3:printf("thirteen\n");break;
      case 4:printf("fourteen\n");break;
   case 5:printf("fifteen\n");break;
      case 6:printf("sixteen\n");break;
   case 7:printf("seventeen\n");break;
      case 8:printf("eighteen\n");break;
   case 9:printf("nineteen\n");break;
      case 0:printf("ten\n");break;
   }
   }
   }
   return 0;
  }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值