您的位置:首页 > 其它

1035. Password (20)

2015-11-15 22:37 197 查看
1.简单的字符串处理

2.注意0,1个没有修改是,是is,大于1个是,是are

//#include<string>
//#include <iomanip>
#include<vector>
#include <algorithm>
//#include<stack>
#include<set>
#include<queue>
#include<map>
//#include<unordered_set>
#include<unordered_map>
//#include <sstream>
//#include "func.h"
//#include <list>
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory.h>
#include<limits.h>
using namespace std;

char replace(char a)
{
switch (a)
{
case'1':return '@';
case'0':return '%';
case'l':return 'L';
case'O':return 'o';
default:return a;
}
}

int main(void)
{
int n;
cin >> n;
vector<pair<string, string>> ans(0);
for (int i = 0; i < n; i++)
{
string name, pw;
cin >> name >> pw;
bool re = false;
for (int i = 0; i < pw.size(); i++)
{
if (pw[i] == '1' || pw[i] == '0' || pw[i] == 'l' || pw[i] == 'O')
{
pw[i] = replace(pw[i]);
re = true;
}
}
if (re)
{
ans.push_back({ name, pw });
}
}
if (ans.size() == 0)
{
if (n<=1)
printf("There is %d account and no account is modified\n", n);
else
printf("There are %d accounts and no account is modified\n", n);

}
else
{
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++)
cout << ans[i].first << " " << ans[i].second << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: