90分求hack,必关
查看原帖
90分求hack,必关
1008234
byk_ALEX楼主2025/7/17 18:52

代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	double s = 0;
	getline(cin, a);
	for(int i = 0; i < a.length(); i++){
		if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
			cout << '.';
			s++;
		}
		else{
			cout << a[i]; 
		}
	}
	bool flag = 0;
	cout << "\n";
    int x, e = 1;
	for(x = 0; x <= a.length() && e <= round(s / 3); x++){
		if(a[x] >= 'a' && a[x] <= 'z' || a[x] >= 'A' && a[x] <= 'Z'){
			cout << a[x];
			e++;
		}
		else{
            cout << a[x];
        }
	}
	for(int j = x; j < a.length(); j++){
        if(a[j] == 'A' || a[j] == 'E' || a[j] == 'I' || a[j] == 'O' || a[j] == 'U' || a[j] == 'a' || a[j] == 'e' || a[j] == 'i' || a[j] == 'o' || a[j] == 'u'){
			flag = 1;
		}
		if(a[j] >= 'a' && a[j] <= 'z' || a[j] >= 'A' && a[j] <= 'Z'){
			cout << '.'; 
		}
		else{
			cout << a[j]; 
		}
	}
	cout << "\n";
	if(flag){
		for(int i = 0; i < round(s / 3); i++){
			cout << a[i];
		}
		for(int i = round(s / 3); i < a.length(); i++){
			if(a[i] == 'A' || a[i] == 'E' || a[i] == 'I' || a[i] == 'O' || a[i] == 'U' || a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u'){
				cout << a[i];
				continue;
			}
			if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
				cout << '.';
				s++;
			}
			else{
				cout << a[i]; 
			}
		}
	}
	else{
		int w = 1;
		int i;
		for(i = 0; i < a.length() && w <= round(s / 3 * 2); i++){
			if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
				cout << a[i];
				w++;
			}
            else{
                cout << a[i];
            }
		}
		for(int j = i; j < a.length(); j++){
			if(a[j] >= 'a' && a[j] <= 'z' || a[j] >= 'A' && a[j] <= 'Z'){
				cout << '.'; 
			}
			else{
				cout << a[j]; 
			}
		}
	}
	return 0;
}
2025/7/17 18:52
加载中...