听说灌水区里大佬多。。。
  • 板块灌水区
  • 楼主shenyixuan123
  • 当前回复10
  • 已保存回复10
  • 发布时间2023/10/1 10:02
  • 上次更新2023/11/2 16:50:42
查看原帖
听说灌水区里大佬多。。。
685824
shenyixuan123楼主2023/10/1 10:02

题目传送门

发题目版里没人回,只好上灌水区来了

70WA,求帮忙。。

#include<bits/stdc++.h>
using namespace std;
string pd(char ch)
{
	if(ch=='0') return "zero";
	if(ch=='1') return "one";
	if(ch=='2') return "two";
	if(ch=='3') return "three";
	if(ch=='4') return "four";
	if(ch=='5') return "five";
	if(ch=='6') return "six";
	if(ch=='7') return "seven";
	if(ch=='8') return "eight";
	if(ch=='9') return "nine";
}
string pd1(char ch)
{
	if(ch=='2') return "twenty";
	if(ch=='3') return "thirty";
	if(ch=='4') return "forty";
	if(ch=='5') return "fifty";
	if(ch=='6') return "sixty";
	if(ch=='7') return "seventy";
	if(ch=='8') return "eighty";
	if(ch=='9') return "ninety";
}
string pd2(char ch)
{
	if(ch=='0') return "ten";
	if(ch=='1') return "eleven";
	if(ch=='2') return "twelve";
	if(ch=='3') return "thirteen";
	if(ch=='4') return "fourteen";
	if(ch=='5') return "fifteen";
	if(ch=='6') return "sixteen";
	if(ch=='7') return "seventeen";
	if(ch=='8') return "eighteen";
	if(ch=='9') return "nineteen";
}
int main()
{
	string s;
	cin>>s;
	if(s.size()==4)
	{
		cout<<pd(s[0])<<" thousand"<<' ';
		if(s[1]==s[2]&&s[2]==s[3]&&s[1]=='0') 
		    return 0;
		if(s[1]==s[2]&&s[1]=='0') 
		{
		    cout<<"and "<<pd(s[3]);
		    return 0;
		}
		if(s[1]!='0')
		{
			cout<<pd(s[1])<<" hundred"<<' ';
		}
		if(s[2]!='0')
		{
			if(s[2]=='1')
			{
				cout<<"and "<<pd2(s[3]);
				return 0;
			}
			if(s[1]=='0') cout<<"and "<<pd1(s[2])<<' ';
			else cout<<pd1(s[2])<<' ';
		}
		if(s[3]!='0')
		{
			if(s[2]=='0') cout<<"and "<<pd(s[2]);
			else cout<<pd(s[3]);
		}
	}
	if(s.size()==3)
	{
		cout<<pd(s[0])<<" hundred"<<' ';
		if(s[1]!='0')
		{
			if(s[1]=='1')
			{
				cout<<"and "<<pd2(s[2]);
			}
			else 
			{
			    cout<<pd1(s[1])<<' ';
			    if(s[2]!='0')
		        {
			        cout<<pd(s[2])<<' ';
		        }
			}
     	}	
	}
	if(s.size()==2) 
	{
	    if(s[1]=='1') cout<<pd2(s[1])<<endl;
	    else cout<<pd1(s[0])<<' '<<pd(s[1])<<endl;
	}
	if(s.size()==1) cout<<pd(s[0])<<endl;
	return 0;
}
2023/10/1 10:02
加载中...