zoukankan      html  css  js  c++  java
  • 1005 Spell It Right (20分)

    1005 Spell It Right (20分)

    题目:

    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
    

    题意:

    计算数字N的每一位合,然后用英语读每一位。

    题解:

    #include <iostream>
    using namespace std;
    
    int main() {
    	long long sum = 0;
    	string n;
    	cin >> n;
    	for(int i=0;i<n.size();i++) sum+=(n[i]-'0');
    	string ans = to_string(sum);
    	string tamp[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
    	for(int i=0;i<ans.size();i++) {
    		if(i) cout << " ";
    		cout << tamp[ans[i]-'0'];
    	}
    	return 0;
    }
    
  • 相关阅读:
    凤凰传奇
    信息孤岛
    别了,中珠
    吃苦要趁早
    触动——beyond歌词
    走出舒适区,迎接挑战
    创新永存
    信息时代
    变色龙时代——创新
    Java基本的数据类型
  • 原文地址:https://www.cnblogs.com/F4lc0n/p/12235207.html
Copyright © 2011-2022 走看看