代码如下(C语言):
#include<stdio.h>
#include<string.h>
int main()
{
int N;
scanf("%d", &N);
getchar();
for(int i = 0; i < N; i++)
{
char pwd[81];
gets(pwd);
int len = strlen(pwd);
if(len < 6)
{
printf("Your password is tai duan le.\n");
continue;
}
else if(len >= 6 && len <= 80)
{
int temp = 0; //非法字符数
int point = 0; //小数点数
int letter = 0; //字母数
int num = 0; //数字数
for(int j = 0; j < len; j++)
{
if((pwd[j] >= 'a' && pwd[j] <= 'z') || (pwd[j] >= 'A' && pwd[j] <= 'Z'))
letter++;
else if(pwd[j] >= '0' && pwd[j] <= '9')
num++;
else if(pwd[j] == '.')
point++;
else
{
temp++;
printf("Your password is tai luan le.\n");
break;
}
}
if(len == letter + point)
printf("Your password needs shu zi.\n");
else if(len == num + point)
printf("Your password needs zi mu.\n");
else if(temp == 0)
printf("Your password is wan mei.\n");
}
}
}
注意:本题中字符串的输入不能用scanf,用scanf输入不会读取空白符。(空白符包括空格、制表符、换行符)