1035. Password

http://pat.zju.edu.cn/contests/pat-a-practise/1035

创建结构体存信息方便。

// 

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

#define SIZE 15
#define MAXSIZE 1000+5
void replace(char a[], char b[])
{
	int i=0;
	while(a[i] != 0)
	{
		switch(a[i])
		{
		case '1': b[i]='@'; break;
		case '0': b[i]='%'; break;
		case 'l': b[i]='L'; break;
		case 'O': b[i]='o'; break;
		default:
			b[i] = a[i];
			break;
		}
		i++;
	}
}

int main()
{
#ifdef ONLINE_JUDGE
#else
	freopen("E:\\in.txt", "r", stdin);
	freopen("E:\\out.txt", "w", stdout);
#endif


	int n;	
	scanf("%d", &n);
	if(n == 1)
	{
		puts("There is 1 account and no account is modified");
		return 0;
	}

	int m=0;
	char name[SIZE], pre[SIZE], after[SIZE];
	char buf[MAXSIZE][SIZE*2];

	
	memset(buf, 0, sizeof(buf));

	int num = n;
	while(num-->0)
	{
		memset(name, 0, sizeof(name));
		memset(pre, 0, sizeof(pre));
		memset(after, 0, sizeof(after));
		scanf("%s %s", name, pre);
		replace(pre, after);
		if(strcmp(pre, after) != 0)
		{
			strcpy(buf[m], name);
			strcat(buf[m], " ");
			strcat(buf[m], after);
			//strcat(buf[m], "\0");
			m++;
		}
	}

	if(m > 0)
	{
		printf("%d\n", m);
		int i;
		for(i=0; i<m; i++)
		{
			printf("%s\n", buf[i]);
		}	
	}
	else
	{
		printf("There are %d accounts and no account is modified\n", n);
	}


	return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值