zoukankan      html  css  js  c++  java
  • PAT 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

    #include <iostream>
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <algorithm>
    #include <math.h>
    #include <queue>
    #include <map>
    #include <strstream>
    #include <string>
    
    using namespace std;
    char a[105];
    map<int,string> m;
    int main()
    {
      m[0]="zero";
      m[1]="one";
      m[2]="two";
      m[3]="three";
      m[4]="four";
      m[5]="five";
      m[6]="six";
      m[7]="seven";
      m[8]="eight";
      m[9]="nine";
      scanf("%s",a);
      int num=0;
      int len=strlen(a);
      for(int i=0;i<len;i++)
        num+=(a[i]-'0');
      string s;
      strstream ss;
      ss << num;
      ss >> s;
      int len2=s.length();
      for(int i=0;i<len2;i++)
      {
        if(i==len2-1)
          cout<<m[s[i]-'0']<<endl;
        else
            cout<<m[s[i]-'0']<<" ";
      }
      return 0;
    
    }


  • 相关阅读:
    斐波那契数列
    斐波那契数列
    .NET (C#)ASP.NET 应用程序与页面生命周期
    .NET (C#) Internals: ASP.NET 应用程序与页面生命周期(意译)
    如何使用:before和:after伪元素?
    学习的网址
    css盒子(box)
    利用Asp.Net来实现“网络硬盘”功能
    Jtemplates ${} or {{html}}的区别
    Jtemplate
  • 原文地址:https://www.cnblogs.com/dacc123/p/8228624.html
Copyright © 2011-2022 走看看