zoj2514 Generate Passwords

Generate Passwords
Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu

Submit Status

Description

To prepare for programming contests or coding examinations, 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

There are multiple test cases. 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. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output

For each 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 "No account is modified."

Sample Input:
2
Team000001 R1spOdfa
Team000002 Rlsp0dfa
1
team110 abcdefg332
0
Sample Output:
2
Team000001 R@spodfa
Team000002 RLsp%dfa
No account is modified.

Source

CYJJ's Funny Contest #1, Killing in Seconds
 
 
 
分析:
坑题。注意用户名是不需要改的,只改密码。另外输出也是个坑,调试了很久。
总之认真读题,仔细分析就行。难度在于编程,不涉及算法。
ac代码:
#include
#include
#include
using namespace std;
char c1[1001][11],c2[1001][11];
int main()
{
    int n,i,j,k;
    int len1,len2;
    int count;
    bool flag[1001];
    //bool flag3[4],flag4[4]
    while(scanf("%d",&n)&&n)
    {
       count=0;
       //flag2=false;
       //flag3={false};
       //flag4={false};
        for(i=0;i         {
            //scanf("%s%s",c1[i],c2[i]);
            cin>>c1[i]>>c2[i];
        }
        //flag={false};
        /*这种写法本地编译没问题,但是提交vjudge,则提示
        extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default],
        意思是编译器告诉你延迟初始化话仅仅在C++0x标准或gnu++ox标准中使用,如果你是要这么做而漏加了选项,那么假如提示的编译选项就可以解决。
        简单讲就是编译器要求数组单个赋值,不能一次性赋值。*/
        for(i=0;i         flag[i]=false;
        for(i=0;i         {
            //len1=strlen(c1[i]);
            len2=strlen(c2[i]);
           /* for(j=0;j             {
                if(c1[i][j]=='1')
                {
                    c1[i][j]='@';
                    flag[i]=true;
                }
                else if(c1[i][j]=='0')
                {
                    c1[i][j]='%';
                    flag[i]=true;
                }
                else if(c1[i][j]=='l')
                {
                    c1[i][j]='L';
                    flag[i]=true;
                }
                else if(c1[i][j]=='O')
                {
                     c1[i][j]='o';
                     flag[i]=true;
                }
            }*/
            for(j=0;j             {
                if(c2[i][j]=='1')
                {
                    c2[i][j]='@';
                    flag[i]=true;
                }
                else if(c2[i][j]=='0')
                {
                    c2[i][j]='%';
                    flag[i]=true;
                }
                else if(c2[i][j]=='l')
                {
                    c2[i][j]='L';
                    flag[i]=true;
                }
                else if(c2[i][j]=='O')
                {
                    c2[i][j]='o';
                    flag[i]=true;
                }
            }
           if(flag[i]) count++;
        }
        if(!count) printf("No account is modified.\n");
        else
        {
            printf("%d\n",count);
            for(i=0;i             {
                if(flag[i])
                cout<             }
        }
    }
    return 0;
}


 

 

你可能感兴趣的:(坑题)