第八个测试点WA,求助
查看原帖
第八个测试点WA,求助
677002
_molee_楼主2024/1/27 20:49
#include<bits/stdc++.h>
using namespace std;
long long n,f,fl,fla;
string num[20]={"a","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"},numty[10]={"a","a","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
int main(){
	cin>>n;
	if(n==0)
	{
		cout<<"zero";
		return 0;
	}
	if(n/1000!=0)
	{
		cout<<num[n/1000]<<" thousand ";
		f=1;
	}
	n%=1000;
	if(n/100!=0)
	{
		cout<<num[n/100]<<" hundred ";
		fl=1;
	}
	else
	{
		if(f==1&&n%100!=0)
		{
			cout<<"and ";
		}
	}
	n%=100;
	if(n/10!=0)
	{
		if(n/10==1)
		{
			cout<<num[10+n%10];
			fla=1;
		}
		else
		{
			cout<<numty[n/10]<<" ";
		}
		fl=1;
	}
	else
	{
		if(f==1&&fl==1&&n%10!=0)
		{
			cout<<"and ";
		}
	}
	n%=10;
	if(n!=0)
	{
		if(fla==0)
		{
			cout<<num[n];
		}
	}
    return 0;
}
2024/1/27 20:49
加载中...