zoukankan      html  css  js  c++  java
  • PATA1035Password

    • 需要注意的就是把判定函数提取出来,这样可以简化代码,同时参数引用了&,可以对于传入参数进行修改。
      参考代码:
    #define _CRT_SECURE_NO_WARNINGS
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    
    struct node
    {
    	char name[20], password[20];
    	bool ischange;//如果ischange==true表示password已经修改
    }T[1005];
    
    //函数用来判断t的password的是否需要修改,若需要则cnt加1
    void crypt(node& t, int& cnt)
    {
    	int len = strlen(t.password);
    	for (int i = 0; i < len; i++)
    	{
    		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)
    	{
    		cnt++;
    	}
    }
    
    int main()
    {
    	int n, cnt = 0;
    	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);
    	}
    	if (cnt == 0)
    	{
    		if (n == 1)
    		{
    			printf("There is %d account and no account is modified", n);
    		}
    		else
    		{
    			printf("There are %d accounts and no account is modified", n);
    		}
    	}
    	else
    	{
    		printf("%d
    ", cnt);
    		for (int i = 0; i < n; i++)
    		{
    			if (T[i].ischange == true)
    			{
    				printf("%s %s
    ", T[i].name, T[i].password);
    			}
    		}
    	}
    
    	system("pause");
    	return 0;
    }
    
    
    作者:睿晞
    身处这个阶段的时候,一定要好好珍惜,这是我们唯一能做的,求学,钻研,为人,处事,交友……无一不是如此。
    劝君莫惜金缕衣,劝君惜取少年时。花开堪折直须折,莫待无花空折枝。
    曾有一个业界大牛说过这样一段话,送给大家:   “华人在计算机视觉领域的研究水平越来越高,这是非常振奋人心的事。我们中国错过了工业革命,错过了电气革命,信息革命也只是跟随状态。但人工智能的革命,我们跟世界上的领先国家是并肩往前跑的。能身处这个时代浪潮之中,做一番伟大的事业,经常激动的夜不能寐。”
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    4 Apr 18 软件开发目录 logging模块的使用 序列化(Json, Pickle) os模块
    3 Apr 18 内置函数 列表生成式与生成器表达式 模块的使用之import 模块的使用之from…import…
    2 Apr 18 三元表达式 函数递归 匿名函数 内置函数
    30 Mar 18 迭代器 生成器 面向过程的编程
    29 Mar 18 函数 有参、无参装饰器
    28 Mar 18 函数
    27 Mar 18 函数的参数
    26 Mar 18 函数介绍
    23 Mar 18 文件处理
    22 Mar 18 补充数据类型+字符编码+文件处理
  • 原文地址:https://www.cnblogs.com/tsruixi/p/11236584.html
Copyright © 2011-2022 走看看