PAT (Basic Level) Practice (中文) 1002 写出这个数

题目链接

 

 

#include <stdio.h>
#include<string.h>
int main(){
  char a[1002];
  int b, c,d,e,g,m[5],n;
  gets(a);
  b = 0;
  c = 0;
  d = 0;
  while (a[b] != '\0') {
    c = c + a[b] - 48;
    b = b + 1;
  }
  for (b = c, n = 0; b; b /= 10, n++) {
    m[n] = b % 10;
    d++;
  }
  for (c = d; c >= 1; c--){
    b = m[c - 1];
  if (b == 0)
    printf("ling");
  else if (b == 1)
    printf("yi");
  else if (b == 2)
    printf("er");
  else if (b == 3)
    printf("san");
  else if (b == 4)
    printf("si");
  else if (b == 5)
    printf("wu");
  else if (b == 6)
    printf("liu");
  else if (b == 7)
    printf("qi");
  else if (b == 8)
    printf("ba");
  else if (b == 9)
    printf("jiu");
  if (c != 1)
    printf(" ");
}
	return 0;
}

 

上一篇:How to sort HashSet in Java


下一篇:1039 到底买不买 (20 分)C++ PAT (Basic Level) Practice