pat解題報告【1082】


1082. Read Number in Chinese (25)
時間の制限
400 ms
メモリ制限
32000 kB
コード長制限
16000 B
クイズルーチン
Standard    
作成者
CHEN, Yue
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way.  Output "Fu"first if it is negative.  For example, -123456789 is read as "Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu".  Note: zero ("ling") must be handled correctly according to the Chinese tradition.  For example, 100800 is "yi Shi Wan ling ba Bai".
Input Specification:
Each input file contains one test case, which gives an integer with no more than 9 digits.
Output Specification:
For each test case, print in a line the Chinese way of reading the number.  The characters are separated by a space and there must be no extra space at the end of the line.
Sample Input 1:
-123456789

Sample Output 1:
Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu

Sample Input 2:
100800

Sample Output 2:
yi Shi Wan ling ba Bai

 
簡単なシミュレーションですが、プロセスの説明がうるさいだけです.
まずどういう意味だ?
Chinese traditionとは、実は0に対する特殊な処理です.
【1】尾の0は発音しない
【2】連続する0が複数あり、1音しか出ない
【3】複数の不連続な0は、すべて発音する
【4】4桁以上の数は必ずWan音を出す
【5】8桁以上の数は必ずYi音を出す
そしてもう一つの法則があります:ShiBai Qianという3つの音の循環が現れます.
 
Acコード:
 
// pat-1082.cpp :              。
//

#include "stdafx.h"

#include "iostream"
#include "string"
#include "algorithm"
#include "vector"
#include "stack"

using namespace std;
stack ans;
string num[]={"ling", "yi" ,"er" , "san" , "si" ,  "wu",  "liu" , "qi",  "ba",  "jiu"};
string pos[]={ "Shi","Bai","Qian", "Wan","Yi" };
int main()
{
	long int n=0;
	bool firstout=true;
	cin>>n;
	if (n==0)
	{
		cout<