PAT | A1035 Password

注意点:n == 1和n > 1时,如果没有密码被改变,输出的格式是不一样的。
n == 1:

There is 1 account and no account is modified

n > 1:

There are 2 accounts and no account is modified

#include <iostream>
#include <vector>

using namespace std;

struct User{
	string username;
	string password;
};

vector<User> users;

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		string name,pwd;
		name.resize(100);
		pwd.resize(100);
		scanf("%s %s",&name[0],&pwd[0]);
		bool modified = false;
		for(int j = 0;j < pwd.size();j++){
			switch(pwd[j]){
			case '1':
				pwd[j] = '@';
				modified = true;
				break;
			case 'l':
				pwd[j] = 'L';
				modified = true;
				break;
			case '0':
				pwd[j] = '%';
				modified = true;
				break;
			case 'O':
				pwd[j] = 'o';
				modified = true;
				break;
			}
		}
		if(modified == true){
			User temp = {name,pwd};
			users.push_back(temp);
		}
	}
	if(users.size() != 0){
		printf("%d\n",users.size());
		for(unsigned int i = 0;i < users.size();i++){
			printf("%s %s\n",users[i].username.c_str(),users[i].password.c_str());
		}
	}
	else{
		if(n > 1){
			printf("There are %d accounts and no account is modified",n);
		}
		else
			printf("There is %d account and no account is modified",n);
	}
	system("pause");
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值