http://pat.zju.edu.cn/contests/pat-a-practise/1035
//字符串转换,输出 使用c++下的string类,此时不能用c的scanf。printf。。
switch case 语句的使用,vector容器的使用
输出的字符串要仔细比对,看细节,there is 与 there are 不同...
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct STU
{
string account;
string password;
};
STU stu[1001];
vector<STU> ans;
int main()
{
int n,i,j;
cin>>n;
for (i=1;i<=n;i++)
{
cin>>stu[i].account;
cin>>stu[i].password;
}
for (i=1;i<=n;i++)
{
bool change=false;
int lp=stu[i].password.size();
for (j=0;j<lp;j++)
{
switch(stu[i].password[j])
{
case '1':
stu[i].password[j]='@';
change=true;
break;
case '0':
stu[i].password[j]='%';
change=true;
break;
case 'l':
stu[i].password[j]='L';
change=true;
break;
case 'O':
stu[i].password[j]='o';
change=true;
break;
default:
break;
}
}
if (change)
{
ans.push_back(stu[i]);
}
}
if (ans.size()==0)
{
if (n==1)
{
cout<<"There is 1 account and no account is modified"<<endl;
}
else
cout<<"There are "<<n<<" "<<"accounts and no account is modified"<<endl;
}
else
cout<<ans.size()<<endl;
for (i=0;i<ans.size();i++)
{
cout<<ans[i].account<<" "<<ans[i].password<<endl;
}
return 0;
}