我是靠谱客的博主 优雅耳机,这篇文章主要介绍密码登录验证,现在分享给大家,希望可以做个参考。

输入密码,有三次机会,每次输入错误后反馈第几次输入。输入成功结束运行。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h> #include<string.h> #include<Windows.h>//Sleep #include<stdlib.h>//system("cls") int main() { int flag = 0; char a[100] = { 0 }; int i = 0; for (i = 0; i < 3; i++) { printf("请输入密码->:n"); scanf("%s", &a); Sleep(1000); system("cls"); //if (a == "1662309375")字符串不能这样判断:strcmp if (strcmp(a, "1662309375") == 0) { printf("登录成功!n"); Sleep(1000); system("cls"); flag = 1; break;//一定记得防止break前 } else { printf("第%d次密码登录失败!n", i + 1); Sleep(1000); system("cls"); } } if (flag == 0) { printf("三次密码登录失败,禁止输入!n"); Sleep(1000); system("cls"); } return 0; }

最后

以上就是优雅耳机最近收集整理的关于密码登录验证的全部内容,更多相关密码登录验证内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(74)

评论列表共有 0 条评论

立即
投稿
返回
顶部