【1035】Password (20 分)

简介: 【1035】Password (20 分)【1035】Password (20 分)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>  
#include<map>
#include<vector>
#include<queue> 
using namespace std;  
//判断密码是否需要修改,注意对结构体的使用和函数的结构化
struct node{
  char name[20],password[20];
  bool ischange;  //ischange==true表示password已被修改
}T[1005];
//crypt函数判断t的password是否需要被修改,若需要则对其修改并令计数器cnt加1
void crypt(node& t,int& cnt){ 
  int len=strlen(t.password);
  for(int i=0;i<len;i++){//枚举password的每一位
    if(t.password[i]=='1'){ 
      t.password[i]='@';
      t.ischange=true;
    }else if(t.password[i]=='0'){ 
      t.password[i]='%';
      t.ischange=true;
    } else if(t.password[i]=='l'){ 
      t.password[i]='L';
      t.ischange=true;
    }else if(t.password[i]=='O'){ 
      t.password[i]='o';
      t.ischange=true;
    }
  }
  if(t.ischange){  //如果t的password已修改,则令计数器cnt加1
    cnt++;
  }
}
int main(){   
  int n,cnt=0;//cnt记录需要修改的password个数
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s %s",T[i].name,T[i].password);
    T[i].ischange=false;  //初始化所有密码未修改
  }
  for(int i=0;i<n;i++){
    crypt(T[i],cnt);  //对T[i]的password判断是否需要修改
  }
  if(cnt==0){ //没有password需要修改
    if(n==1){
      printf("There is %d account and no account is modified",n);
    }else{ //注意这里account的单复数和is/are的使用
      printf("There are %d accounts and no account is modified",n);
    }
  }else{  //如果有password需要修改
    printf("%d\n",cnt);  //修改的password个数
    for(int i=0;i<=n;i++){
      //如果T[i]的password需要修改,则输出name和password
      if(T[i].ischange){
        printf("%s %s\n",T[i].name,T[i].password);
      }
    }
  }
  system("pause");
    return 0;   
}
相关文章
|
编译器 数据库 C++
参数化查询 '(@UserName nvarchar(1),@PassWord nvarchar(4000))Select * from Us未提供“@PassWord”参数
参数化查询 '(@UserName nvarchar(1),@PassWord nvarchar(4000))Select * from Us未提供“@PassWord”参数
135 0
|
数据安全/隐私保护
password题解
password题解
102 0
password题解
|
数据安全/隐私保护 关系型数据库 Oracle
使用PASSWORD_VERIFY_FUNCTION设置用户密码复杂度
依据PASSWORD_VERIFY_FUNCTION可以设置oracle用户的密码复杂度,比如密码长度>=10,必须包含字母/数字等首先需要创建一个密码验证的function,然后设置profile的PASSWORD_VERIFY_FUNCTION即可 SQL> s...
4482 0
|
程序员 数据安全/隐私保护
问题 E: Double Password
ICPC总部的一台电脑有一个四位数字的密码保护——为了登录,你通常需要准确地猜出这四位数字。然而,实现密码检查的程序员在计算机上留下了一个后门——有第二个四位数字的密码。如果程序员输入一个四位数的密码序列,并且输入的每一个数字的位置至少与两个相同位置的密码中的一个匹配,那么这个四位数的密码序列将使程序员登录计算机。给定这两个密码,计算可以输入登录计算机的不同四位数字序列的数量。
172 0
【1126】Eulerian Path (25分)【连通图】
1)如果是一个连通图,则只需要一次DFS即可完成遍历。 (2)可以用DFS判断一个无向图是否
170 0
【1113】Integer Set Partition (25分)
【1113】Integer Set Partition (25分) 【1113】Integer Set Partition (25分)
112 0
【1021】Deepest Root (25 分)
【1021】Deepest Root (25 分) 【1021】Deepest Root (25 分)
95 0
|
索引
1035. Password (20)
To prepare for PAT, the judge sometimes has to generate random passwords for the users.
990 0
|
数据安全/隐私保护