当前位置: 代码迷 >> 综合 >> 1035 Password (20 分)
  详细解决方案

1035 Password (20 分)

热度:99   发布时间:2023-12-05 06:51:24.0

题目在此

https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520

#include <iostream>
#include <vector>
using namespace std;
int main() {int n;cin>>n;vector<string> v;for(int i = 0; i < n; i++) {string name, s;//用户名和密码 cin >> name >> s;int len = s.length(), flag = 0;for(int j = 0; j < len; j++) {switch(s[j]) {case '1' : s[j] = '@'; flag = 1; break;//数字1 case '0' : s[j] = '%'; flag = 1; break;//数字0 case 'l' : s[j] = 'L'; flag = 1; break;//小写L case 'O' : s[j] = 'o'; flag = 1; break;//大写O }}if(flag) //有需要修改的密码 {string temp = name + " " + s;v.push_back(temp);//加入到vector数组中 }}int cnt = v.size();if(cnt != 0) //输出需要修改的密码 {printf("%d\n", cnt);//输出个数 for(int i = 0; i < cnt; i++)cout << v[i] << endl;} else 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);}return 0;
}

  相关解决方案