题目链接
题目大意:
给n个数据,每个数据包括学号密码;if密码有1 0 O l这几个字符要对其进行修改,并且统计修改的数据最后连同学号输出;
if没有则另外输出指定语句;
代码中有注释方便理解;
#pragma warning(disable:4996);
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<stack>
#include<math.h>
#include<vector>
using namespace std;
struct sec {
string a;//学号
string s;//密码
int flag = 0;//是否需要修改
}buf[1005];
int main() {
int n;
cin >> n;
int tflag = 0;//统计总的修改个数,if为0,说明没有修改;
for (int i = 0;i < n;i++)
{
getchar();
cin >> buf[i].a;
getchar();
cin >> buf[i].s;
for (int j = 0;j < buf[i].s.size();j++)
{
if (buf[i].s[j] == '1' || buf[i].s[j] == '0' || buf[i].s[j] == 'l' || buf[i].s[j] == 'O')
{//进行密码的判断;
buf[i].flag = 1;
tflag++;
break;
}
}
}
//特殊情况的处理;
if (tflag == 0 && n != 1) cout << "There are " << n << " accounts and no account is modified" << endl;
else if (tflag == 0 && n == 1)cout << "There is 1 account and no account is modified" << endl;
else {
cout << tflag << endl;
for (int i = 0;i < n;i++)
{
if (buf[i].flag == 1) {
for (int j = 0;j < buf[i].s.size();j++)
{
if (buf[i].s[j] == '1') buf[i].s[j] = '@';
if (buf[i].s[j] == '0') buf[i].s[j] = '%';
if (buf[i].s[j] == 'l') buf[i].s[j] = 'L';
if (buf[i].s[j] == 'O') buf[i].s[j] = 'o';
}//修改数据并输出
cout <<buf[i].a <<" "<<buf[i].s << endl;
}
}
}
return 0;
}