1035. Password

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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值