1035. Password (20)
来源:互联网 发布:最近mmd喵萝脸型数据 编辑:程序博客网 时间:2024/06/06 03:03
1035. Password (20)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.
Input Specification:
Each input file contains one test case. Each case contains a positive integer N (<= 1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.
Output Specification:
For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line "There are N accounts and no account is modified" where N is the total number of accounts. However, if N is one, you must print "There is 1 account and no account is modified" instead.
Sample Input 1:
3Team000002 Rlsp0dfaTeam000003 perfectpwdTeam000001 R1spOdfaSample Output 1:
2Team000002 RLsp%dfaTeam000001 R@spodfaSample Input 2:
1team110 abcdefg332Sample Output 2:
There is 1 account and no account is modifiedSample Input 3:
2team110 abcdefg222team220 abcdefg333Sample Output 3:
There are 2 accounts and no account is modified
#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>int convert(char b[15]){int i=0,flag =0;while(b[i] != 0){if(b[i] == '1'){b[i] = '@';flag =1;}if(b[i] == '0'){b[i] = '%';flag =1;}if(b[i] == 'l'){b[i] ='L';flag =1;}if(b[i] == 'O'){b[i] = 'o';flag =1;}i++;}return flag;}main(){int N,i,j=0,count=0;char a[1000][15],b[1000][15];scanf("%d",&N);for(i=0;i<N;i++){scanf("%s%s",a[j],b[j]);if( convert(b[j]) ){j++;count ++;}}if(count != 0){printf("%d\n",count);}else{if(N == 1){puts("There is 1 account and no account is modified");}else{printf("There are %d accounts and no account is modified\n",N);}}i = 0;while(i+1 <= count ){printf("%s %s\n",a[i],b[i]);i++;}}
- 1035. Password (20)
- 【PAT】1035. Password (20)
- 1035. Password (20)-PAT
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- PAT 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- pat 1035. Password (20)
- 腾讯风铃建站系统使用
- 矩阵旋转90度
- 二分法简介
- Uva-10891(dp专组B)
- [C++]继承与面向对象设计
- 1035. Password (20)
- SVN学习
- JAVAACRIPT基础教程(第8版)---第8章_处理事件
- 锦标赛问题 - 递归
- leetcode 067 Add Binary
- 【链式队列】接口的封装
- Scanner的用法
- http协议学习笔记(二)
- 虚拟机的三种网络连接方式