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 }
  • 相关阅读:
    Hive性能分析和优化方法
    浅谈MySQL中优化sql语句查询常用的30种方法
    spark 源码阅读博客
    spark shell学习笔记
    用shell 实现对MySQL数据库分页
    hive 1.2 配置
    spark1.4配置安装
    HBase学习
    【转】解密饿了么大前端团队
    【转】我心目中的支付宝架构
  • 原文地址:https://www.cnblogs.com/yomman/p/4275144.html
Copyright © 2011-2022 走看看