机械硬盘写入速度:C高手请进
来源:百度文库 编辑:高考问答 时间:2024/05/04 19:56:10
高手们 超级菜鸟来请教问题了 请问能不能让下面这个“密码”函数(的一部分)实现输入三次密码 如果不行的话 才执行printf语句 而在三次以内输入错误的话就输出“请重新输入”
void changepassword()
{
printf("please enter your password: \n");
static int n=1234;int t,k;
scanf("%d",&k);[K是密码]
if(k!=n)
{
printf(" sorry! the password is worng!the serves has stop!\n");exit(0);
}
void changepassword()
{
printf("please enter your password: \n");
static int n=1234;int t,k;
scanf("%d",&k);[K是密码]
if(k!=n)
{
printf(" sorry! the password is worng!the serves has stop!\n");exit(0);
}
void changepassword()
{
printf("please enter your password: \n");
static int n=1234;int t,k;
for ( t = 0; t < 3; t++ )
{
scanf("%d",&k);[K是密码]
if(k==n)
{
break;
}
printf( "retry:" );
}
if ( t == 3 )
{
printf(" sorry! the password is worng!the serves has stop!\n");exit(0);
}
}
n赋值为3,k=0,进行++k,当k<=n时,循环结束。