国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT A1082. Read Number in Chinese (25/21)

2019-11-11 01:09:22
字體:
來源:轉載
供稿:網友

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:
-123456789Sample Output 1:
Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiuSample Input 2:
100800Sample Output 2:
yi Shi Wan ling ba Bai
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 300using namespace std;struct user{	char name[11];	char pas[11];}a[Max],b[Max];char getc(char a[],int m){	return a[strlen(a)-1-m];}int main(){	int m,m1=0,m2=0,m3=0,k1,k2,k3,cc=0;	int a[11],b[11],c[11];	char z[5][10]={"Qian","Bai","Shi"};	char s[11][11]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};	for(int i=0;i<11;i++)	{		a[i]=b[i]=c[i]=0;	}	scanf("%d",&m);	if(m<0){		printf("Fu ");		m=-m;	}	m1=m/(100000000);	m2=(m-m1*100000000)/10000;	m3=m-m1*100000000-m2*10000;	k1=m1;k2=m2;k3=m3;	if(m==0) printf("ling");	else {		if(m1!=0)		{			cc=1;			int k=0,x=0;			while (m1>0)		{			a[3-k]=m1%10;			m1=m1/10;			k++;		}			for(int i=0;i<4;i++)			{												if(a[i]!=0)				{										printf("%s",s[a[i]]);										if(z[i]!=NULL&&i<=2)						printf(" %s",z[i]);					if(a[i+1]!=0||a[i+2]!=0||a[i+3]!=0) printf(" ");				}			}			printf(" Yi");		}		if(m2!=0)		{						if (k1!=0) printf(" ");			int k=0,x=0;			while (m2>0)		{			b[3-k]=m2%10;			m2=m2/10;			k++;		}			for(int i=0;i<4;i++)			{				if(i>=1)				{					if(x==0&&cc!=0){					printf("ling ");					x=1;					}				}				if(b[i]!=0)				{					cc=1;					x=1;					printf("%s",s[b[i]]);									if(z[i]!=NULL&&i<=2)						printf(" %s",z[i]);						if(b[i+1]!=0||b[i+2]!=0||b[i+3]!=0) printf(" ");				}			}			printf(" Wan");		}		if(m3!=0)		{		  if(k2!=0||(k2==0)&&k1!=0)	printf(" ");			int k=0,x=0;			while (m3>0)		{			c[3-k]=m3%10;			m3=m3/10;			k++;		}			for(int i=0;i<4;i++)			{				if(i>=1)				{					if(x==0&&cc!=0){					printf("ling ");					x=1;					}				}				if(c[i]!=0)				{					x=1;					printf("%s",s[c[i]]);										if(z[i]!=NULL&&i<=2)						printf(" %s",z[i]);					if(c[i+1]!=0||c[i+2]!=0||c[i+3]!=0) printf(" ");				}			}		}	}	system("pause");	return 0;}
上一篇:Hdu 1062

下一篇:關鍵路徑

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灯塔市| 行唐县| 吴江市| 太仆寺旗| 濉溪县| 昭苏县| 成安县| 措美县| 甘肃省| 炎陵县| 武义县| 丰都县| 中江县| 鄂伦春自治旗| 阳城县| 九龙城区| 万源市| 和静县| 赤壁市| 西乌| 虎林市| 荥阳市| 平阴县| 东乡县| 开原市| 临湘市| 桑日县| 扎兰屯市| 甘泉县| 柘城县| 厦门市| 济阳县| 吉木萨尔县| 白城市| 龙州县| 兴山县| 南皮县| 宁晋县| 马鞍山市| 灵武市| 庄浪县|