题解 | #学英语#

学英语

http://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc

#include <stdio.h>
#include <string.h>



void transform_three_num(int n);
int main()
{
int n;
while(scanf("%d",&n)!=EOF){
int a,b,c;
c = n%1000;
b = (n/1000)%1000;
a = n/1000000;

if(a){
  transform_three_num(a);
  printf(" million");
}

if(a!=0 && b!=0 )
printf(" ");
if(b){

  transform_three_num(b);
  printf(" thousand");
}

if(b!=0 && c!=0 ||  a!=0 && c!=0 )
printf(" ");
if(c){
  transform_three_num(c);
}

printf("\n");

}






  return 0;
}


void transform_three_num(int n){
int single,ten,hundred;
hundred = n/100;
ten = (n/10)%10;
single = n%10;
switch (hundred)
{
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;
default:
  break;
}
if(hundred!=0 && ten+single!=0){
  printf(" and ");
}

if(ten ==1){
  switch(n%100){
    case 10:
    printf("ten");
    break;
        case 11:
    printf("eleven");
    break;
        case 12:
    printf("tweleve");
    break;
        case 13:
    printf("thirteen");
    break;
        case 14:
    printf("fourteen");
    break;
        case 15:
    printf("fifteen");
    break;
        case 16:
    printf("sixteen");
    break;
        case 17:
    printf("seventee");
    break;
        case 18:
    printf("eighteen");
    break;
        case 19:
    printf("nineteen");
    break;
  }
}
else{
  switch (ten)
  {
  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;
default:
  break;
  }


if(ten!=0 && single!=0)
printf(" ");
 switch (single)
  {
    case 1:
  printf("one");
  break;
case 2:
  printf("two");
  break;
  case 3:
  printf("three");
  break;
  case 4:
  printf("four");
  break;
  case 5:
  printf("five");
  break;
  case 6:
  printf("six");
  break;
  case 7:
  printf("seven");
  break;
  case 8:
  printf("eight");
  break;
  case 9:
  printf("nine");
  break;
default:
  break;
  }

}


}




全部评论

相关推荐

找不到工作死了算了:没事的,雨英,hr肯主动告知结果已经超越大部分hr了
点赞 评论 收藏
分享
沉淀一会:**圣经 1.同学你面试评价不错,概率很大,请耐心等待;2.你的排名比较靠前,不要担心,耐心等待;3.问题不大,正在审批,不要着急签其他公司,等等我们!4.预计9月中下旬,安心过节;5.下周会有结果,请耐心等待下;6.可能国庆节前后,一有结果我马上通知你;7.预计10月中旬,再坚持一下;8.正在走流程,就这两天了;9.同学,结果我也不知道,你如果查到了也告诉我一声;10.同学你出线不明朗,建议签其他公司保底!11.同学你找了哪些公司,我也在找工作。
点赞 评论 收藏
分享
3 2 评论
分享
牛客网
牛客企业服务