有三次机会输入密码
以下代码供参考
#include"stdio.h" #include"string.h" int main() { char p[10] = "love"; char in[10]; int i = 0, count = 2; for (i = 0; i <= count;) { gets_s(in); if (strcmp(p, in) == 0) { printf("right password ! welcome !\n"); } else { printf("wrong password !you still have %d time\n", count); } count--; } }
那个time 加个复数太麻烦,本身也不重要
小白一个,欢迎指正。
0.0分
0 人评分