-
题目大意:检查密码里是否有1、l、0、o,如果检测到了就分别replace 1 (one) by @, 0 (zero) by %, l by L, and O by o
-
知识点:
- string
- vector:
- v.pushback(1):往v最后面插入一个1
python里是v.append(1)
- v.pushback(1):往v最后面插入一个1
-
代码:
#include <iostream> #include <string> #include <vector> using namespace std; int main(){ int n, cnt = 0; string account, passport; vector<string> a, p; cin >> n; for(int i = 0; i < n; i++){ cin >> account >> passport; bool flag = false; for(int j = 0; j < passport.length(); j++){ if(passport[j] == '1' || passport[j] == 'l' || passport[j] == '0' || passport[j] == 'O'){ flag = true; if(passport[j] == '1') passport[j] = '@'; if(passport[j] == 'l') passport[j] = 'L'; if(passport[j] == '0') passport[j] = '%'; if(passport[j] == 'O') passport[j] = 'o'; } } if(flag){ cnt++; a.push_back(account); p.push_back(passport); } } if(cnt == 0) if(n == 1) printf("There is 1 account and no account is modified"); else printf("There are %d accounts and no account is modified", n); else{ cout << cnt << endl; for(int i = 0; i < cnt; i++) printf("%s %s\n", a[i].c_str(), p[i].c_str()); } return 0; }
-
总结:
-
注意输出格式!!!
n = 1:are变is,accounts变account。
-
09-08
174
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-02
155
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)