#include<stdio.h>
#include<string.h>
int main()
int i = 0;
char password[20] = { 0 };
for (i = 0; i < 3; i++)
printf("请输入密码:");
scanf("%s", password);
if (strcmp(password, "123456") == 0)
printf("密码正确\n");
break;
if (i < 2)
printf("密码错误,还有%d尝试机会:\n", 2 - i);
if (i == 3)
printf("三次密码均错误,退出程序\n");
return 0;