c语言:用户输入用户名和密码,判断是否合法用户(用户名为abc,密码为123456)

如果合法,显示"welcome to use the software",否则要求重新输入,允许输入3次,若3次都错,显示“password error!you can not use software".

#include <stdio.h>;
#include <stdlib.h>;

main(){
int key,i;
printf("请输入密码:\n");
scanf("%d",&key);
if(key==123)
printf("welcome to use the software!\n");
else{
printf("请输入密码:");
scanf("%d",&key);
if(key==123)
printf("welcome to use the software!\n");
else{
printf("请输入密码:");
scanf("%d",&key);
if(key==123)
printf("welcome to use the software!\n");
else printf("password error!you can not use software!\n");
}
}
system("pause");
}

这是最笨的方法,它可用循环实现,你自己想想去做
温馨提示:答案为网友推荐,仅供参考
相似回答