限制三次机会输入正确密码
int main(){ int i = 0; char password[] = "123456"; for (i = 0; i < 3; i++) { printf("请输入密码\n"); scanf("%s", &password); if (strcmp(password, "123456") == 0) { printf("恭喜,密码正确\n"); break; } } if (i == 3) { printf("三次密码都错误,推出程序\n"); } return 0;}