1005. Spell It Right (20)
来源:互联网 发布:jmeter 相应数据乱码 编辑:程序博客网 时间:2024/05/15 23:48
这个题简单,就直接贴在这吧,注意一点输入数据规模比较大,要用char来存储
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:12345Sample Output:
one five
// 1005. Spell It Right.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include<iostream>#include<vector>#include<string>using namespace std;void printSpelling(int number){switch (number){case 0:cout << "zero";break;case 1:cout << "one";break;case 2:cout << "two";break;case 3:cout << "three";break;case 4:cout << "four";break;case 5:cout << "five";break;case 6:cout << "six";break;case 7:cout << "seven";break;case 8:cout << "eight";break;case 9:cout << "nine";break;default:break;}}int _tmain(int argc, _TCHAR* argv[]){vector<char> input;char temInput;//输入while (true){temInput = cin.get();if (temInput == '\n')break;input.push_back(temInput);}//求和int sum = 0;for (int i = 0; i < input.size(); i++)sum += input[i] - '0';//输出vector<int> output;if (sum == 0)output.push_back(0);elsewhile (sum > 0){output.push_back(sum % 10);sum = sum / 10;}//打印for (int i = 0; i < (int)output.size() - 1; i++){printSpelling(output[output.size()-i-1]);cout << " ";}//打印最后一个if (output.size() > 0)printSpelling(output[0]);system("pause");return 0;}
0 0
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 用StringBuffer求两个字符串的前缀
- 2.1.3
- Objective-C 程序内存分布
- 1024. Palindromic Number (25)PAT甲级
- RNA-seq流程报告
- 1005. Spell It Right (20)
- BIM工作,急需出台建模标准和数据标注
- 莱蒙托夫《帆》
- 51NOD 1536 不一样的猜数游戏 数论
- GameMaker: Studio 学习笔记(一)Sprite Editor
- Spark Shuffle初探
- QT基础
- java编写的爬虫爬取煎蛋的图片
- IIS7部署MVC4网站在本机正常,发布(部署)报403.14错误