俺是不是太笨了,只会if,如果没如果。。。
#include<stdio.h>
#include<string.h>
int main() {
int len = 0, upralpha = 0, lwralpha = 0, digital = 0, other = 0;
char str[301] = {'\0'};
int grade = 0;
while (~scanf("%s", str)) {
len = strlen(str); //字符串长度
for (int i = 0; i < len; i++) {
if ('A' <= str[i] && 'Z' >= str[i]) upralpha = 1; //标记是否有大写字母
else if ('a' <= str[i] && 'z' >= str[i]) lwralpha = 1; //标记是否有小写字母
else if ('0' <= str[i] && '9' >= str[i]) digital++; //记录数字个数
else other++; //记录其他符号个数
}
//密码长度:
if (len <= 4) grade += 5;
else if (5 <= len && 7 >= len) grade += 10;
else grade += 25;
//字母:
if (upralpha + lwralpha == 0) grade += 0;
else if (upralpha + lwralpha == 1) grade += 10;
else grade += 20;
//数字:
if (digital == 0) grade += 0;
else if (digital == 1) grade += 10;
else grade += 20;
//符号:
if (other == 0) grade += 0;
else if (other == 1) grade += 10;
else grade += 25;
//奖励:
if (upralpha + lwralpha == 2 && digital >= 1 && other >= 1) grade += 5;
else if (upralpha + lwralpha == 1 && digital >= 1 && other >= 1) grade += 3;
else if (upralpha + lwralpha == 1 && digital >= 1) grade += 2;
// printf("%d\n",grade); //测试得分是否计算正确
if (grade >= 90) printf("VERY_SECURE\n");
else if (grade >= 80) printf("SECURE\n");
else if (grade >= 70) printf("VERY_STRONG\n");
else if (grade >= 60) printf("STRONG\n");
else if (grade >= 50) printf("AVERAGE\n");
else if (grade >= 25) printf("WEAK\n");
else printf("VERY_WEAK\n");
}
}