还没有解决!!请大佬帮帮忙吧
查看原帖
还没有解决!!请大佬帮帮忙吧
580339
Cheney__22楼主2022/3/27 16:58

subtask1 #7 只有这一个点WA了 球球大佬舅舅蒟蒻

#include<bits/stdc++.h>
using namespace std;
int m;
string word[1001],c;
string s1[10]={"","one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
string s2[10]={"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
string s3[10]={"", "ten", "twenty", "thirty", "forty", "fifteen", "sixty", "seventy", "eighty", "ninety"};
string s4[1]={"hundred"};
int ge,shi1,shi2,bai;
string jiashu(int s)
{
	int x=s;
	string shu;
	ge=x%100%10;
	shi1=x%100;
	shi2=shi1/10;
	bai=x/100;
	if(bai!=0){
		shu=s1[bai]+s4[0];
	}
	if(shi1>0&&shi1<=19){
		if(shi1>0&&shi1<=9){
			shu=shu+s1[ge];
		}
		if(shi1>=10&&shi1<=19){
			shu=shu+s2[ge];
		}
	}
	else if(shi1>=20){
		shu=shu+s3[shi2]+s1[ge];
	}
	return shu;
}
int main()
{
	/*for(int i=1;i<=999;i++){
		cout<<i<<"="<<jiashu(i)<<endl;
	}*/
	int s,loong,l;
	cin>>s;
	for(int i=1;i<=s;i++){
		cin>>word[i];
	}
	for(int i=1;i<=s;i++){
		if(word[i]!="$"){
			c=c+word[i];
		}
	}
	loong=c.size();
	l=loong;
	while(1){
		c=jiashu(loong);
		//cout << loong << " " << c << " " << c.size() << endl;
		//cout << "l = " << l << endl;
		if(loong==c.size()+l){
			break;
		}
		loong++;
	}
	for(int i=1;i<=s;i++){
		if(word[i]=="$"){
			word[i]=c;
		}
	}
	for(int i=1;i<=s;i++){
		cout<<word[i]<<" ";
	}
	return 0;
}
2022/3/27 16:58
加载中...