[0618]Tyvj1128中文大写数字
模擬題,數據太弱了,完全沒有我現象的幾個結果。
采用遞歸打印。
#?include?<iostream>
#?include?<string.h>
using?namespace?std;
bool?large(int?a[])
{
?for?(int?i?=?5;?i?<=?8;?i++)
??if?(a[i]?!=?0)
???return?true;
?return?false;
}
int?print(int?len,?int?ch[],?int?b)
{
?if?(len?==?1)
?{
??if?(ch[len?+?b]?!=?0)
??{
???if?(ch[len?+?b?+?1]?==?0)
????cout?<<?"0";
???cout?<<?ch[len?+?b];
??}
??return?0;
?}
?if?(len?==?2)
?{
??if?(ch[len?+?b]?!=?0)
??{
???if?(ch[len?+?b?+?1]?==?0)
????cout?<<?"0";
???cout?<<?ch[len?+?b]?<<?"shi";
??}
??print(len?-?1,?ch,?b);
??return?0;
?}
?if?(len?==?3)
?{
??if?(ch[len?+?b]?!=?0)
???cout?<<?ch[len?+?b]?<<?"bai";
??print(len?-?1,?ch,?b);
??return?0;
?}
?if?(len?==?4)
?{
??if?(ch[len?+?b]?!=?0)
???cout?<<?ch[len?+?b]?<<?"qian";
??print(len?-?1,?ch,?b);
??return?0;
?}
?if?((len?>?4)?&&?(len?<?9))
?{
??print(len?-?4,?ch,?4);
??if?((ch[5]?!=?0)?||?(ch[0]?>?5)?&&?(large(ch)?==?true))
???cout?<<?"wan";
??print(4,?ch,?0);
??return?0;
?}
?if?(len?>?8)
?{
??print(len?-?8,?ch,?8);
??if?((ch[9]?!=?0)?||?(ch[0]?>?9))
???cout?<<?"yi";
??print(8,?ch,?0);
??return?0;
?}
?return?0;
}
void?rep(int?num[],?char?ch[])
{
?num[0]?=?strlen(ch);
?for?(int?i?=?num[0];?i?>=?1;?i--)
??num[i]?=?ch[num[0]?-?i]?-?48;
}
int?main()
{
?char?da[20];
?cin?>>?da;
?int?len?=?strlen(da);
?int?a[len?+?1];
?rep(a,?da);
?int?temp?=?0;
?for?(int?i?=?a[0];?i?>=?1;?i--)
??if?(a[i]?!=?0)
???temp++;
?if?(temp?!=?0)
??print(len,?a,?0);
?else
??cout?<<?"0";
?return?0;
}
轉載于:https://www.cnblogs.com/shy-/archive/2012/06/18/2553909.html
總結
以上是生活随笔為你收集整理的[0618]Tyvj1128中文大写数字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Jquery原理
- 下一篇: SQL语句获取数据库名、所有表名、所有字