为什么第二个cout没有输出呢,在VS下自测正常
字符串加密的这道题,我在VS下自测完全正常,而牛客上只输出了一行,大家帮我看看这是为啥?
#include<iostream> #include<string> using namespace std; void encrypt(string &src){ for(size_t i=0;i<src.size();++i){ if(isalpha(src[i])){ if(src[i]!='y') ++src[i]; else src[i]='a'; //转换大小写 if(isupper(src[i])) src[i]=tolower(src[i]); else src[i]=toupper(src[i]); } else{ if(src[i]!='9') ++src[i]; else src[i]='0'; } } } void unencrypt(string &src){ for(size_t i=0;i<src.size();++i){ if(isalpha(src[i])){ if(src[i]!='a') --src[i]; else src[i]='y'; //转换大小写 if(isupper(src[i])) src[i]=tolower(src[i]); else src[i]=toupper(src[i]); } else{ if(src[i]!='0') --src[i]; else src[i]='9'; } } } int main() { string s1,s2; while(cin>>s1>>s2){ encrypt(s1); unencrypt(s2); cout<<s1<<endl; cout<<s2<<endl;//这一行没有被输出 } return 0; }