灵异事件 输出一模一样却WA

P1071 [NOIP2009 提高组] 潜伏者

字符串有些时候是这样的
by Xile @ 2023-10-13 21:51:53


是不是输出了多余空格啊?
by yinzifan @ 2023-10-13 22:00:33


@[yinzifan](/user/996790) 输出多余空格不是判对吗
by Logic_LiZidong @ 2023-10-14 12:56:07


不会啊,空格也算字符,输出多余字符不会判对啊(部分题目)
by yinzifan @ 2023-10-14 17:04:12


天哪!真的一样!!!w(゚Д゚)w
by yinzifan @ 2023-10-14 17:11:53


```cpp #include <iostream> #include <string> using namespace std; int main() { string x,y,z; cin>>x>>y>>z; int f[27]={},t[27]={},cnt=0; char s[27]={}; for(int i=0;i<x.size();i++) { if(f[x[i]-'A'+1]==0&&t[y[i]-'A'+1]==0) { s[x[i]-'A'+1]=y[i]; f[x[i]-'A'+1]=1; t[y[i]-'A'+1]=1; cnt++; } else if(s[x[i]-'A'+1]!=y[i]) { cout<<"Failed"; return 0; } } if(cnt!=26) { cout<<"Failed"; return 0; } for(int i=0;i<z.size();i++) { cout<<s[z[i]-'A'+1]; } return 0; } ``` 不用输出空格啊。 代码仅供参考,不可抄袭,违者必究。
by xzwdqjdx @ 2023-10-22 11:08:19


|