讨论 / 谁能帮我看看下面这个C++程序有什么问题
ZWJZWJ 2023-07-03 21:28:21
点我顶贴 收藏 删除
#include<bits/stdc++.h>

using namespace std;

int main(){

string s,a,b,c;

getline(cin,s);

a=s;

int v=0,bv=int(s.size()*1.0/3+0.5),cv=int(s.size()*2.0/3+0.5),i;

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

if(isalpha(s[i])){

a[i]='.';

}

if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U'){

v++;

}

}

b=a;

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

if(i<bv&&isalpha(s[i])){

b[i]=s[i];

}

}

c=b;

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

if(v!=0){

if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U'){

c[i]=s[i];

}

}else{

if(i<cv&&isalpha(s[i])){

c[i]=s[i];

}

}

}

cout<<a<<endl;

cout<<b<<endl;

cout<<c<<endl;

}

查看更多回复
提交回复