用户密码管理保存器C语言程序

用户密码管理保存器C语言程序,第1张

#include <stdio.h>

#include <conio.h>

#include <string.h>

void getusr(char *s)

{ printf("渗激简input username:")

gets(s)

}

void getpass(char *s)

{

int i=0

printf("input pass:")

while((s[i]=getch())!='\r')

{ putchar('*')

i++

}

s[i]=0

putchar('\n')

}

void show(char *s)

{ int i,len

char c

len=strlen(s)

for(i=0i<leni++,s++)

{ c=*s+i+1

putchar(c)

}

}

int main()

{ int i

char user[50],pass[50],t[50]

while(1)

{ getusr(user)

i=strlen(user)

if(i>=1&&i<=12)break

}

while(1)

{ getpass(pass)

i=strlen(pass)

if(i>=3&&i<=10)break

}

printf("\nlogin please...\n")

while(1)

{ while(1)

{ getusr(t)

if(!strcmp(t,user))break

printf("铅羡there is no user\n\丛裤n")

}

getpass(t)

if(!strcmp(t,pass))break

printf("password wrong\n\n")

}

printf("welcome %s!\n",user)

show(pass)

return 0

}

#include<stdio.h>

#include<malloc.h>

#include<math.h>

#include<stdlib.h>

#include<time.h>

typedef struct node

{

int num

int password

struct node *next

}Node,*Linklist

shuchu(Linklist LK,Linklist LM) /*输出所有箱子情况界面*/

{

Linklist p,q

p=LK->困并乎next

q=LM->next

while(p)/*空箱*/

{

printf(" ******\n")

printf(" **\n")

printf(" **\n")

printf(" ******\n")

if(p->password) printf(" 红色\n\n")

else printf(" 蓝色\n\n")

p=p->next

}

while(q)/*满箱*/

{

printf(" ******\n")

printf(" **\n")

printf(" **\n")

printf(" ******\n")

if(q->password) printf(" 红色\n\n\n")

else printf(" 蓝色\n\n")

q=q->next

}

}

cunbao(Linklist LK,Linklist LM) /*存包*/

{

Linklist p,q

srand((unsigned)time(NULL))

q=LM->next

p=LK->next

if(!p) /*判断箱子是否已空*/

{

printf("箱满,请稍侯!\n\n")

return

}

while(p->password=rand()%900000+100000) /*生成密码*/

{

if(!q) break

q=LM->next

while((p->password!=q->password))

{

q=q->next

if(!q) break

}

if(!q) break

}

q=LM /*空箱满想的链接*/

while(q->next)

{

q=q->next

}

LK->next=p->next

q->next=p

p->next=NULL

shuchu(LK,LM)

printf(" 申请成功!您的密码是:")

printf("%d\n\n",p->password)

}

qubao(Linklist LK,Linklist LM) /*取包*/

{

Linklist p,q,t

int n

q=LM->next

t=LM

p=LK

printf("请输入您的密码:\n")

scanf("%d",&n)

while(q&&(q->password!=n))

{

q=q->next

t=t->汪悉next

}

if(!q) /*判断密码是否正确*/

{

printf("您输入的密码错误!\n\n"蔽雹)

return

}

q->password=0

t->next=q->next

q->next=LK->next

LK->next=q

shuchu(LK,LM)

}

void main()

{

Linklist LK,LM,p,q

int i=0,n,j

LK=(Linklist)malloc(sizeof(Node)) /*生成链表*/

p=LK

while(i<10)

{

q=(Linklist)malloc(sizeof(Node))

q->num=0

q->password=0

printf(" ******\n")

printf(" **\n")

printf(" **\n")

printf(" ******\n")

if(q->password) printf(" 红色\n\n\n")

else printf(" 蓝色\n\n")

p->next=q

p=p->next

i++

}

p->next=NULL

LM=(Linklist)malloc(sizeof(Node))

LM->next=NULL

do/*主界面*/

{

printf(" ★==尊敬的客户,您好!==★ \n\n")

printf("==========================================================\n\n")

printf(" 1,存包 \n\n")

printf(" 2,取包 \n\n")

printf(" 0,退出 \n\n")

printf("==========================================================\n\n")

printf("请输入序号执行您的 *** 作:\n\n")

scanf("%d",&n)

switch(n)

{

case 1:cunbao(LK,LM)break

case 2:qubao(LK,LM)break

case 0:break

}

}while(n)

}

1、用一个字符数组来存密码

再用一个字符数组接收你的输入,然后用strcmp

来比较,如果返回0则密码是正确的

2、例程:

#include "stdio.h"

#include "string.h"

int main()

{

       char mima[100]="YuanShi888"

       char input[100]={0}

       printf("请输入密码:")

        gets(input)

   含仿岩    if(strcmp(mima,input)==0)

        大灶    printf("恭喜你,密码正确!\n")

       else

            printf("对不起,密码输入错误谈御!\n")

  

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8255175.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存