1 #define _CRT_SECURE_NO_WARNINGS 1 2 #include<stdio.h> 3 #include<string.h> 4 int main() 5 { 6 int i; 7 char password[20]={0}; 8 for (i = 0; i < 3; i++) 9 { 10 printf("请输入密码"); 11 scanf("%s",password); 12 if (strcmp(password, "123woheta" ) == 0) 13 { 14 printf("密码正确,登陆成功"); 15 break; 16 } 17 else 18 printf("密码输入错误,"); 19 } 20 if (3 == i) 21 printf("请退出程序"); 22 return 0; 23 }