求助
查看原帖
求助
1374810
yin55楼主2025/1/13 17:32

有没有大佬能帮我看看

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string arr[22] = {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
	string s;
	int flag = 0;
	int a[6] = {0};
	int j = 0;
	while(cin >> s && s != "."){
		for(int i = 0; i <= 20; i++){
			if(s == arr[i]) {
				a[j] = i * i % 100;
				j++;
				break;
			}
		}
		if(s == "a" || s == "another" || s == "first"){
			a[j] = 1;
			j++;
		}else if(s == "both" || s == "second"){
			a[j] = 4;
			j++;
		}else if(s == "third"){
			a[j] = 9;
			j++;
		}
	}
	int first = 1;
	sort(a, a + j, less<int>());
	
	for(int i = 0; i < j; i++){
		if(a[i] < 10 && a[i] > 0){
			if(first){
				cout << a[i];
				first = 0;
			}else{
				cout << '0' << a[i];
			}
		}else if(a[i] == 0){
			continue;
		}else cout << a[i];
	}
	return 0;
}
2025/1/13 17:32
加载中...