PAT:1035. Password (20) AC

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

typedef struct STU
{
  char mID[15];
  char mpass[15];
  bool tag;
}STU;

STU arr[1010];
int main()
{
  memset(arr,0,sizeof(arr));
  int n,change=0;
  scanf("%d",&n);
  for(int i=0 ; i<n ; ++i)
  {
    scanf("%s %s",&arr[i].mID,&arr[i].mpass);
    int len=strlen(arr[i].mpass);
    int tag=0;                //判断这个输入是否改过
    for(int j=0 ; j<len ; ++j)
    {
      if(arr[i].mpass[j]==‘1‘){
        ++tag;
        arr[i].tag=1;
        arr[i].mpass[j]=‘@‘;
      }
      else if(arr[i].mpass[j]==‘0‘){
        ++tag;
        arr[i].tag=1;
        arr[i].mpass[j]=‘%‘;
      }
      else if(arr[i].mpass[j]==‘O‘){
        ++tag;
        arr[i].tag=1;
        arr[i].mpass[j]=‘o‘;
      }
      else if(arr[i].mpass[j]==‘l‘){
        ++tag;
        arr[i].tag=1;
        arr[i].mpass[j]=‘L‘;
      }
    }
    if(tag!=0)
      ++change;              //记录改变数的个数
  }
  if(n==1 && change==0)
    printf("There is 1 account and no account is modified");
  else if(n>1 && change==0)
    printf("There are %d accounts and no account is modified",n);
  else
  {
    printf("%d\n",change);
    for(int i=0 ; i<n ; ++i)
    {
      if(arr[i].tag==1)
        printf("%s %s\n",arr[i].mID,arr[i].mpass);
    }
  }
  return 0;
}
时间: 2024-12-16 07:51:51

PAT:1035. Password (20) AC的相关文章

PAT甲级——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)

PAT Advanced 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)

PAT:1077. Kuchiguse (20) AC

#include<stdio.h> #include<string.h> char in[100][260]; int main() { int n,lenMIN=260; scanf("%d",&n); getchar(); //[skill]吸收换行符 for(int i=0 ; i<n ; ++i) { gets(in[i]); int len=strlen(in[i]); if(len<lenMIN) lenMIN=len; for(

PAT:1008. Elevator (20) AC

#include<stdio.h> int main() { int n,ans=0,now=0; //要停n层,ans是总时间,now代表当前层数 scanf("%d",&n); for(int i=0 ; i<n ; ++i) { int tmp; scanf("%d",&tmp); if(tmp>now) //上楼,每上一层6秒 { ans+=(tmp-now)*6; now=tmp; } else if(tmp<

PAT 1035. Password (20)

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) fro

PAT甲题题解-1035. Password (20)-水

题意:给n个用户名和密码,把密码中的1改为@,0改为%,l改为L,O改为o. 让你输出需要修改密码的用户名个数,以及对应的用户名和密码,按输入的顺序.如果没有用户需要修改,则输出对应的语句,注意单复数... 没啥好说的,就for一遍密码,把需要改的改下,存入到ans中去. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cm

PAT 甲级 1035 Password

https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520 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 di

1035 Password (20)

1 #include <stdio.h> 2 #include <string.h> 3 struct MyStruct 4 { 5 char ID[11]; 6 char Password[11]; 7 bool changed; 8 }; 9 int main() 10 { 11 int n,i,j; 12 MyStruct User[1001]; 13 while(scanf("%d",&n)!=EOF) 14 { 15 for(i=0;i<

PAT:1003. Emergency (25) AC

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int MAXV=510; const int INF=0x3fffffff; int n,m,c1,c2; bool vis[MAXV]; int G[MAXV][MAXV]; //城市间距离 int weight[MAXV]; //每个城市的救援人数 int d[MAXV]; //最短距离 int w