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;
    
    }


  • 相关阅读:
    CSS3 box-shadow(阴影使用)
    缩小窗口时CSS背景图出现右侧空白BUG的解决方法
    html打开个人QQ聊天页面
    帮助你实现元素动画的6款插件
    给出两个颜色,计算中间颜色返回数组
    名字首字母
    自适应网页设计
    tab切换jquery代码
    改变上传文件样式
    剑指offer 面试16题
  • 原文地址:https://www.cnblogs.com/dacc123/p/8228624.html
Copyright © 2011-2022 走看看