考察对应字符转化以及信息记录
#include<iostream>
#include<string.h>
#include<vector>
typedef struct user
{
char name[20];
char password[20];
bool modified;
}User;
bool IsModified(User& a)
{
int len = strlen(a.password);
bool ret = false;
for(int i = 0; i < len; ++i)
{
if(a.password[i] == '1')
{
a.password[i] = '@';
ret = true;
}
else if(a.password[i] == '0')
{
a.password[i] = '%';
ret = true;
}
else if(a.password[i] == 'l')
{
a.password[i] = 'L';
ret = true;
}
else if(a.password[i] == 'O')
{
a.password[i] = 'o';
ret = true;
}
}
return ret;
}
int main()
{
int N;
while(scanf("%d", &N) != EOF)
{
std::vector<User> userVec(N);
int modifiedCnt = 0;
for(int i = 0; i < N; ++i)
{
scanf("%s %s",userVec[i].name, userVec[i].password);
if( IsModified(userVec[i]) )
{
userVec[i].modified = true;
modifiedCnt++;
}
else userVec[i].modified = false;
}
//output
if(modifiedCnt == 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
{
printf("%d\n", modifiedCnt);
for(int i = 0; i < N; ++i)
{
if(true == userVec[i].modified)
{
printf("%s %s\n", userVec[i].name, userVec[i].password);
}
}
}
}
return 0;
}