zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    短URL
    Linux安装MySQL
    Ubuntu中安装MySQL
    安装交叉工具链arm-linux-gcc
    Linux安装—IP设置
    Linux内核概述
    Bash变量
    Shell登陆
    Linux—查看远程Linux系统运行时间
    Linux—查看路由
  • 原文地址:https://www.cnblogs.com/yomman/p/4275144.html
Copyright © 2011-2022 走看看