#include <iostream>
#include <string>
using namespace std;
int main()
{
string str="This is a sample";
int begin,end;
int j=0;
for(int i=0;i<16;i++)
{
if(str[i]>=65&&str[i]<=90&&str[i]!=' '){
str[i]+=32;
continue;
}
if(str[i]>=97&&str[i]<=122&&str[i]!=' ')
str[i]-=32;
}
reverse(str.begin(),str.end());
while(str[j])
{
if(str[j]!=' ')
{
begin=j;
while(str[j]!=' '&&str[j])
j++;
j=j-1;
end=j;
}
while(end>begin)
{
char temp;
temp=str[begin];
str[begin]=str[end];
str[end]=temp;
begin++;
end--;
}
j++;
}
cout<<str<<endl;
return 0;
}
牛客网一站通Offer考试第一题
最新推荐文章于 2022-08-02 15:10:41 发布