蒟蒻求助
查看原帖
蒟蒻求助
632635
WOERDESUGX楼主2022/10/3 15:34
#include<bits/stdc++.h>

using namespace std;
string s[105]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
int n;
int main()
{
    s[20]="twenty";s[30]="thirty";s[40]="forty";s[50]="fifty";s[60]="sixty";s[70]="seventy";s[80]="eighty";s[90]="ninety";
    cin>>n;
    if(n>=0&&n<=20) {
        cout<<s[n];return 0;
    }
    if(n/1000!=0) cout<<s[n/1000]<<" thousand";
    if(n/100%10!=0) cout<<" "<<s[n/100%10]<<" hundred";
    if(n%100!=0) {
        if(n/100!=0) {
            if(n%100/10>1) {
                cout<<" "<<s[n%100/10*10];
                if(n%100%10!=0) cout<<" "<<s[n%100%10];
            }
            else if(n%100/10==1) {
                if(n%100==10) cout<<" and "<<s[n%100];
                else cout<<" "<<s[n%100];
            }
            else if(n%100/10==0)cout<<" and "<<s[n%10];
        }
    }
    return 0;
}
2022/10/3 15:34
加载中...