编写一个简单的输入密码的程序有三次机会

#include<stdio.h>

#include<string.h>
int main()
{
	 char name[]="shoushou";
   char passworld[]="123456";
	int count=3;
	


	while(count>0)
	{
	char name_[32];
	char passworld_[32];
	printf("please enter your name:");
	scanf("%s",name_);
	printf("please enter your passworld:");
	scanf("%s",passworld_);//在循环里定义并且读入。
		if(0==strcmp(name,name_)&&0==strcmp(passworld,passworld_))
		{
			printf("success!");
			break;
		}
	    else
		{
			count--;
			printf("your passworld or name is wrong!");
			
			printf("you have %d times\n",count);
		}
		if(count<=0)
		{
			printf("you do not have chance,please start anew!");
			
			}

		}
	}


	

猜你喜欢

转载自blog.csdn.net/shoushou_/article/details/89785992
今日推荐