• 1005. Spell It Right


    1005. Spell It Right (20)

    时间限制
    400 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.

    Input Specification:

    Each input file contains one test case. Each case occupies one line which contains an N (<= 10100).

    Output Specification:

    For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.

    Sample Input:
    12345
    
    Sample Output:
    one five
     1 #include<stdio.h>
     2 #include<math.h>
     3 #include<stdlib.h>
     4 #include<string.h>
     5 
     6 int main()
     7 {
     8     char n[150], num[10][20] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
     9     gets(n);
    10     int sum = 0, i, len;
    11     len = strlen(n);
    12     for(i = 0; i < len; i++)
    13     {
    14         sum += n[i] - '0';
    15     }
    16     int a[100];
    17     i = 0;
    18     do{
    19         a[i] = sum % 10;
    20         sum /= 10;
    21         i++;
    22     }while(sum != 0);
    23     for(i = i -1; i > 0; i--)
    24     {
    25         printf("%s ", num[a[i]]);
    26     }
    27     printf("%s
    ", num[a[0]]);
    28     return 0;
    29 }
  • 相关阅读:
    1.选择排序法
    24.桌面移动qq
    23.控制语句题目
    23.位运算实现加法
    22.dll调用技术
    21.MFC进制转换工具
    2.CString转换到char*
    20.原码反码补码及图形化界面
    11gR2 Agent 简介
    RAC数据库后台进程介绍
  • 原文地址:https://www.cnblogs.com/yomman/p/4275144.html
Copyright © 2020-2023  润新知