总结:
1.scanf()以空格或者回车结束
2.gets()只以回车结束
3.如果gets()之前有scanf()一定要用getchar()吃掉回车。
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(){
char password[80];
int quantity_user;
int dot_count=0;
int num_count=0;
int character_count=0;
int lock=0;
scanf("%d",&quantity_user);
getchar();
for (int i = 0; i < quantity_user; ++i) {
gets(password);
int j;
int signal;
for (signal= 0;signal<strlen(password) ; ++signal) {
}
if(signal<6){
printf("Your password is tai duan le.\n");
continue;
}
for (j = 0;password[j]!=0 ; ++j) {
if(password[j]=='.'){
dot_count++;
} else if(password[j]>='0'&&password[j]<='9'){
num_count++;
} else if((password[j]>='a'&&password[j]<='z')||(password[j]>='A'&&password[j]<='Z')){
character_count++;
} else{
printf("Your password is tai luan le.\n");
lock=1;
break;
}
}
if(lock==0){
if(num_count<1){
printf("Your password needs shu zi.\n");
} else if (character_count<1){
printf("Your password needs zi mu.\n");
}else{
printf("Your password is wan mei.\n");
}
}
lock=0;
dot_count=0;
num_count=0;
character_count=0;
}
return 0;
}