1035 Password (20 分)

1035 Password (20 分)

题意

给出一组成员信息,包括成员名字和密码,如果密码中有‘1’就改成‘@’,有‘0’就改成‘%’,有‘l’(小写L)就改成’L‘,有’O‘就改成’o’。
输出要修改密码的人数,以及这些人修改后的信息(名字 修改后的密码)
如果没有人的密码要修改,则输出“There are N accounts and no account is modified”,N是改组成员的总人数,如果N为1,则输出为“There is 1 account and no account is modified”

思路

建立成员信息结构体,包含姓名和密码,以及一个修改位。检测密码是否需要修改并修改,并把该成员的修改为设为1,方便后面输出修改成员的信息时的判断。
最后判断总人数以及需要修改的人数,把需要修改成员的信息输出。
注意N为1时的输出不同。

代码

#include<stdio.h>
#include<string.h>

typedef struct node{
	char name[20],password[20];
	bool modify=0;
}node;

node member[2007];

void print(int n,int count)
{
	if(count==0){
		if(n==1){
			printf("There is 1 account and no account is modified\n");
		}else{
			printf("There are %d accounts and no account is modified\n",n);
		}
	}else{
		printf("%d\n",count);
		for(int i=0;i<n;i++){
			if(member[i].modify==1){
				printf("%s %s\n",member[i].name,member[i].password);
			}
		}
	}
}

int main()
{
	
	int n,count=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		getchar();
		scanf("%s %s",member[i].name,member[i].password);
		for(int j=0;j<strlen(member[i].password);j++){
			if(member[i].password[j]=='1'){
				member[i].modify=1;
				member[i].password[j]='@';
			}
			if(member[i].password[j]=='0'){
				member[i].modify=1;
				member[i].password[j]='%';
			}
			if(member[i].password[j]=='l'){
				member[i].modify=1;
				member[i].password[j]='L';
			}
			if(member[i].password[j]=='O'){
				member[i].modify=1;
				member[i].password[j]='o';
			}
		}
		if(member[i].modify==1){
			count++;
		}
	}
	print(n,count);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值