这道题对我来说有些困难,用了很长时间(并看了柳神的代码)才解决,下面这个blog是对vector容器的各种函数的介绍:
https://blog.csdn.net/ak201605050122/article/details/80225297
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<string> v;
int n;
scanf("%d", &n);
for(int j = 0; j < n; j++){
string name, s;
cin >> name >> s;
int flag = 0;
for(int i = 0; i < s.length(); i++){
switch(s[i]) {
case '1' : s[i] = '@'; flag = 1; break;
case '0' : s[i] = '%'; flag = 1; break;
case 'l' : s[i] = 'L'; flag = 1; break;
case 'O' : s[i] = 'o'; flag = 1; break;
}
}
if(flag){
string temp = name + " " + s;
v.push_back(temp);
}
}
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;
}
网友评论