文章
28
粉丝
230
获赞
23
访问
244.0k
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
string str,lock1,lock2;
while((cin>>lock1)&&lock1=="START"){
cin.ignore();//cin与getline连用要用cin.ignore()消除回车字符
getline(cin,str);
for (int i = 0; i < str.length(); ++i)
{
if ('A'<=str[i]&&str[i]<='Z')
{
cout<<(char)((str[i] - 'A' + 21)%26 + 'A');
}else if(str[i]==','){
cout<<',';
}else{
cout<<' ';
}
}
cout<<endl;
if(cin>>lock2&&lock2=="ENDOFINPUT")
{
break;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发