int main(){
char text[500];
int j,h,op;
char b[]=" abcdefghijklmnopqrstuvwxyz";
char a[]=" ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout<<"insert text:";fflush(stdin);gets(texto);
system("cls");
cout<<"1-Minus to Mayus"<<endl;
cout<<"2-Mayus to Minus"<<endl;
cin>>op;
system("cls");
if (op==1)
{
j=0;
h=0;
while(j<28){
if(text[h]==b[j]){
text[h]=a[j];
h++;
j=0;
}
j++;
}
cout<<text<<endl;
system("pause");
}
else if (op==2)
{
j=0;
h=0;
while(j<28){
if(text[h]==a[j]){
text[h]=b[j];
h++;
j=0;
}
j++;
}
cout<<text<<endl;
system("pause");
}
}
这段代码只适用于单个世界(直到第一个空格),我希望它运行一个完整的句子甚至一个段落。我希望你能理解 main() 中的从低到高的逻辑