zoukankan      html  css  js  c++  java
  • Spell It Right

    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 (≤).

    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<string.h>
     3 #include<stdlib.h>
     4 int main(){
     5     char n[100];
     6     char str[100];
     7     char *m[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
     8     int temp,sum=0,i=0;
     9     scanf("%s",n);
    10     for(i=0;i<strlen(n);i++){
    11         temp=n[i]-'0';
    12         sum+=temp;
    13     }
    14     sprintf(str,"%d",sum);
    15     int b=str[strlen(str)-1]-'0';
    16     for(i=0;i<strlen(str)-1;i++){
    17         int a=str[i]-'0';
    18         printf("%s ",m[a]);
    19     }
    20     printf("%s",m[b]);
    21     return 0;
    22 }
  • 相关阅读:
    Zookeeper入门(三)之工作流
    Zookeeper入门(二)之基础
    Zookeeper入门(一)之概述
    Docker删除/停止容器
    webbench安装和简单使用
    Notepad++ 7.3.2 Download 64-bit x64 / 32-bit x86
    7 常见问题
    6 完整测试
    5 安装Alloc服务
    4 安装MPush
  • 原文地址:https://www.cnblogs.com/muchenyu/p/11957480.html
Copyright © 2011-2022 走看看