#include
#include
char unit[4][33]={"","THOUSAND","MILLION"};
char low[10][33]={"ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
char two[10][33]={"TEN","ELEVEN","TWELVE","THIRTTEN","FOURTEEN","FIFTEEN","SIXTEEN","SEVENTEEN","EIGHTEEN","NINETEEN"};
char high[10][33]={"ZERO","TEN","TWENTY","THIRTY","FORTY","FIFTY","SIXTY","SEVENTY","EIGHTY","NINETY"};
char hd[33]="HUNDRED";
void trans(int n,int deep)
{
char dig[100]={0};
if(n==0)return ;
if(n/100>0)
{
strcat(dig,low[n/100]);
strcat(dig," ");
strcat(dig,hd);
strcat(dig," ");
}
n%=100;
if(n==0)
{
;
}
else if(n0)
{
strcat(dig,unit[deep]);
strcat(dig," ");
}
printf("%s",dig);
}
void out(int n,int deep)
{
if(n==0)return;
out(n/1000,deep+1);
trans(n%1000,deep);
}
int main()
{
int sum=0;
int T,n=0,i;
char s[1000];
scanf("%s",s);
for(i=0;s[i]!='.';i++)n=n*10+s[i]-'0';
for(i++;s[i];i++)sum=sum*10+s[i]-'0';
if(n==0)
{
printf("ZERO ");
}
else out(n,0);
printf("AND %d/100",sum);
return 0;
}
C++ this is the second problem Continuing the last one. thx a lot
C++ this is the second problem Continuing the last one. thx a lot
Problem 2*
Continuing the discussion of the previous example, we reiterate the importance of designing check-writing systems to prevent alteration of check amounts. One common security method requires that the check amount be written both in numbers, and spelled out in words as well. Even if someone is able to alter the numerical amount of the check, it is extremely difficult to change the amount in words. Many computerized check-writing systems do not print the amount of the check in words. Perhaps the main reason for this omission is the fact that most high-level languages used in commercial applications do not contain adequate string manipulation features. Another reason is that the logic for writing word equivalents of check amounts is somewhat involved. Write a C++ program that inputs a numeric check amount and writes the word equivalent of the amount.
For example, the amount 112.43 should be written as ONE HUNDRED TWELVE AND 43/100 DOLLARS. Your program should be able to handle amounts up to 1 million dollars.
Problem 2*
Continuing the discussion of the previous example, we reiterate the importance of designing check-writing systems to prevent alteration of check amounts. One common security method requires that the check amount be written both in numbers, and spelled out in words as well. Even if someone is able to alter the numerical amount of the check, it is extremely difficult to change the amount in words. Many computerized check-writing systems do not print the amount of the check in words. Perhaps the main reason for this omission is the fact that most high-level languages used in commercial applications do not contain adequate string manipulation features. Another reason is that the logic for writing word equivalents of check amounts is somewhat involved. Write a C++ program that inputs a numeric check amount and writes the word equivalent of the amount.
For example, the amount 112.43 should be written as ONE HUNDRED TWELVE AND 43/100 DOLLARS. Your program should be able to handle amounts up to 1 million dollars.
其他人氣:904 ℃時間:2019-11-06 05:19:26
優(yōu)質(zhì)解答
我來回答
類似推薦
- the second last 與 last second 的區(qū)別
- look at the three cakes.one is a circle .the second one is a ______and the last one is a ________
- What is the third to last letter of the second to last word of this sentence?
- ① Is this the factory ______ you visited last week① Is this the factory ______ you visited last w
- Is this factory (the one)I visited last week .
- 重多音字組詞
- A.B倆地相距1800千米,一列快車和一列慢車同時從A.B倆地開出,相向而行,15小時后相遇,已知快車每小時比慢
- 大學(xué)基礎(chǔ)化學(xué)和普通化學(xué)這兩個過程有什么不同啊?
- 40個陳述句改反問句
- 如何讓自己的語文成績提高?
- 什么是化學(xué)之最?和化學(xué)主要研究物質(zhì)的什么?
- 在一定溫度,壓強(qiáng)下,向100mLCH4和Ar的混合氣體通入400mLO2,點燃使其完全反應(yīng),最后在相同條件下得到干燥氣體460mL,則反應(yīng)前混合氣體中CH4和Ar的物質(zhì)的量之比為多少
猜你喜歡
- 1已知a,b,c€(-1,1),求證:abc+2>a+b+c.
- 2x³y-2x²y²+xy³
- 3能使物體浮起來的氣體有哪些?
- 4《走一步再走一步》文中最生動、最細(xì)膩、幾乎貫穿整個故事情節(jié)的,是對“我”哪個方面的描寫
- 5祖國,祝你生日快樂(英語怎么說)
- 6生產(chǎn)要素所有者得到的收入是勞動的工資和()
- 7heard和listen to的意思是一樣的嗎?
- 8已知m.n為方程x的平方減3x+l等于零的兩個根,求代數(shù)式-n的平方+3n分之m的平方減3m+2012的值
- 9現(xiàn)有一滿偏電流為500μA,內(nèi)阻為1.2×103Ω的電流表,某同學(xué)想把它改裝成中值電阻為600Ω的歐姆表,(中值電阻:電阻調(diào)零后,當(dāng)測量待測電阻時,電流表指針指在表盤中央時所對應(yīng)的阻值)
- 10下列敘述錯誤的是 A.原生動物都是單細(xì)胞動物 B 環(huán)節(jié)動物的身體由許多體節(jié)組成 C節(jié)肢動物身體分節(jié)
- 11求方向向量a=(2,4)的直線截拋物線y^2=12x所得的弦長為√15的直線的方程
- 12it would mean that we'd have to move to L.A.