简单的口令检查程序(c程序设计)

简单的口令检查程序(c程序设计),第1张

#include<stdio.h>

#include<string.h>

main()

{int cs=0

int pw=8888

int lr

printf('Please enter the password:)

scanf(%d,lr)

while(cs<3)

{if(lr=pw)

{printf('You are welcome!')

cs=3}

else

{printf('\nWrong passward!\n')

cs++

printf('Enter again:\n')

scanf(%d,lr)

}

if(lr!=pw)

{printf('You have entered three times! You are not welcom!')

}}

一下吧

#include <stdio.h>

#define UC (1U<<1) // upper case

#define LC (1U<<2) // lower case

#define NUM (1U<<3) // 0-9

#define ALL (UC|LC|NUM)

int check(const char pass1[], const char pass2[])

{

const char *p = &pass1[0]

unsigned int flag = 0

if (strlen(pass1) <6 || strlen(pass1) >8)

{

printf("password length is 6 to 8.\n")

return 1

}

if (strcmp(pass1, pass2))

{

printf("the tow passwords are diffrence.\n")

return 2

}

while (*p)

{

if (*p >= 'a' &&*p <= 'z') flag |= LC

else if (*p >= 'A' &&*p <= 'Z') flag |= UC

else if (*p >= '0' &&*p <= '9') flag |= NUM

else

{

printf("in valid charactor: %c.\n", *p)

return 3

}

++p

}

if (flag == ALL) return 0

if ((flag &UC) == 0)

{

printf("lack of uppercase.\n")

}

if ((flag &LC) == 0)

{

printf("lack of lowercase.\n")

}

if ((flag &NUM) == 0)

{

printf("lack of number.\n")

}

return -1

}

int main(int argc, char *argv[])

{

char pass1[100]

char pass2[100]

do {

printf("input password:")

scanf("%s", pass1)

printf("repeat password:")

scanf("%s", pass2)

} while (check(pass1, pass2) != 0)

return 0

}


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

原文地址: http://outofmemory.cn/yw/12037998.html

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

发表评论

登录后才能评论

评论列表(0条)

保存