C++版本 22:紧急措施

33 篇文章 2 订阅
23 篇文章 1 订阅

22:紧急措施

描述

近日,一些热门网站遭受黑客入侵,这些网站的账号、密码及email的数据惨遭泄露。你在这些网站上注册若干账号(使用的用户名不一定相同),但是注册时使用了相同的email。你此时拿到了那份泄露的数据,希望尽快将自己的密码更改。策略如下:根据email找到你的用户名和密码,然后更改密码。更改的规则为:小写和大写交换,非字母字符保持不变。

输入

第一行为你的email地址,长度不超过50个字符且只包含字母、数字和‘@’符号。
第二行为账号数N,N(0 < N < 10000)。
接下来N行,每行表示一个账号,格式为:
用户名 密码 email
它们之间用单个空格分开。用户名、密码、email均不含空格,且长度不超过50个字符。

输出

有若干行,每行为你的一个账号,包括:你的账号,修改后的密码(之间用单个空格分隔)。如果没有你的账号,则输出empty。

样例输入

样例输入1:
abc@pku.edu.cn
5
helloKitty iLoveCats abc@pku.edu.cn
2012 maya2012 cplusplus@exam.com
KittyCat 5iKitty abc@pku.edu.cn
program password teacher@exam.com
whoAmi Feb.29$ abc@pku.edu.cn
样例输入2:
abc@pku.edu.cn
1
2012 maya2012 cplusplus@exam.com

样例输出

样例输出1:
helloKitty IlOVEcATS
KittyCat 5IkITTY
whoAmi fEB.29$
样例输出2:
empty
#include<iostream>
#include<cstring>
using namespace std;
struct account{
	string name;
	string pwd;
	string email;
}p[10005];
int main(){
	string s;
	int n, ans = 0;
	cin >> s >> n;
	for(int i = 0; i < n; i++){
		cin >> p[i].name >> p[i].pwd >> p[i].email; 
	}
	for(int i = 0; i < n; i++){
		if(s == p[i].email){
			ans++;
			for(int j = 0; j < p[i].pwd.length(); j++){
				if(p[i].pwd[j] >= 'a' && p[i].pwd[j] <= 'z' || p[i].pwd[j] >= 'A' && p[i].pwd[j] <= 'Z'){
					if(islower(p[i].pwd[j])){
						p[i].pwd[j] -= 32;
					}else{
						p[i].pwd[j] += 32;
					}
				}
			}
		}
	} 
	if(ans != 0){
		for(int i = 0; i < n; i++){
			if(s == p[i].email){
				cout << p[i].name << " " << p[i].pwd << endl;
			}
		}
	}else{
		cout << "empty";
	}
	
}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值