码迷,mamicode.com
首页 > 其他好文 > 详细

PAT:1035. Password (20) AC

时间:2015-02-21 16:37:26      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

#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;
}

PAT:1035. Password (20) AC

标签:

原文地址:http://www.cnblogs.com/Evence/p/4297052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!