答案:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{int n = 0;int count1 = 0, count2 = 0, count3 = 0;scanf("%d", &n);while (n--){char ch[100];scanf("%s", ch);int len = strlen(ch);if (len >= 8) //满足长度条件的话,判断下一个条件{if (!isdigit(ch[0])) //满足首元素条件的话,判断下一个条件{for (int i = 0; i < len; i++) //从第一个元素到最后一个元素{if (isalpha(ch[i]) || isdigit(ch[i])) //满足类型范围的话,判断有几种类型{if (ch[i] >= 'A' && ch[i] <= 'Z') //如果有大写字母类型{count1 = 1; //大写计数器从0变为1}else if (ch[i] >= 'a' && ch[i] <= 'z') //如果有小写字母类型{count2 = 1; //小写计数器从0变为1}else //如果是数字类型{count3 = 1; //数字计数器从0变为1}}else //不满足类型范围{printf("NO\n");}if (i == len - 1) //如果所有字符都已经判断完{if ((count1 + count2 + count3) >= 2) //如果满足类型种类要求{printf("YES\n"); //所有条件都满足了}else //不满足类型种类要求{printf("NO\n");}}}}else //不满足首元素条件{printf("NO\n");}}else //不满足长度条件{printf("NO\n");}}return 0;
}