程序原样告诉我有 0 个大写字母 0 个小写字母 0 个空格和 0 个制表符,但一个具有 2 个小写字母名称的数组还有 61 个其他字符。这些名称由 10 个字母组合而成。我想我需要一个循环来遍历数组,但我不确定这是否正确或我将如何做到这一点。
for (i=0; i<n_names; i++){
printf("%d: [[%s]]\n", i, names[i]);}
for (i=0; i<20; i++){
gets(names[i]);
while (s[i] != 0)
{
if (s[i] >= 'a' && s[i] <= 'z') {
lowercase++;
i++;
}
else if (s[i] >= 'A' && s[i] <= 'Z') {
uppercase++;
i++;
}
else if (s[i] == ' ') { /* Tab - write '\t' for clarity! */
tab++;
i++;
}
else if (*names[i] == ' ') {
spaces++;
i++;
}
else {
other++;
i++;
}
}
}
printf("Your string has %d lowercase letter(s) \n",lowercase);
printf("Your string has %d uppercase letter(s) \n",uppercase);
printf("Your string has %d tab(s) \n",tab);
printf("Your string has %d space(s) \n", spaces);
printf("Your string has %d other character(s) \n",other);