精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • 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.
    其他人氣:904 ℃時間:2019-11-06 05:19:26
    優(yōu)質(zhì)解答
    #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;
    }
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點,以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版