50pts求助
查看原帖
50pts求助
961351
nightwatch.ryan楼主2024/1/19 10:59
#include<iostream>

#include<cctype>

#define debug std::cout<<2023<<"->2024\n"; 

std::string t1,t2,t3;

std::string sub="aeiouAEIOU";

int letcnt;

// int f(double x){
//     int ff=x;
//     double t=x-ff;
//     if(t>=0.5)return ff+1;
//     else return ff;
// }
int main(){

	std::string s;

	getline(std::cin,s);

	for(int i=0;i<s.size();i++){

		if(isalpha(s[i]))t1+=".",letcnt++;

		else t1+=s[i];

	} 

	//double t=1.0*letcnt/3;
    int tmp=(letcnt*1.00/3+0.5);
    //std::cout<<tmp<<'\n';
	int cnt=0,indexoflastLet=0;

	bool f=1;

	for(int i=0;i<s.size();i++){

		if(cnt==tmp and f){

			indexoflastLet=i-1;

			f=false;

		}

		if(cnt<tmp and isalpha(s[i])){

			t2+=s[i];

			cnt++;

		} 

		else if(cnt>=tmp and isalpha(s[i])){

			t2+=".";

		}

		else if(isblank(s[i])){

			t2+=" ";

		}

		else {

			t2+=s[i];

		}

	}

	bool hasYuanyin=0;

	for(int i=indexoflastLet;i<s.size();i++){

		if(sub.find(s[i])!=std::string::npos)hasYuanyin=1;

	}

	t3=t2;

	if(hasYuanyin){

		for(int i=indexoflastLet;i<s.size();i++){

			if(sub.find(s[i])!=std::string::npos){

				t3[i]=s[i];

			}

		}

	}else{

		t3=t2;

		int temper=letcnt*(2*1.00/3+0.5);

		//std::cout<<temper<<'\n';

		int cnt=0;

		for(int i=0;i<s.size();i++){

			if(isalpha(s[i]) and cnt<temper){

				cnt++;

				t3[i]=s[i];

			}

		}

	}

	std::cout<<t1<<'\n'<<t2<<'\n'<<t3;;

}
2024/1/19 10:59
加载中...