在运行这个时如何看到字母表中打印的所有字母?

  • 本文关键字:打印 字母表 运行 何看 c
  • 更新时间 :
  • 英文 :

#include <stdio.h>
int main(){
int i = 0;
int count[26] = {0};
char str[100];
printf("Ord: ");
scanf("%s", &str);
printf("Frekvens: n");
while (str[i] != ''){
if (str[i]>= 'a' && str[i] <= 'z'){
int x = str[i] -'a';
count[x]++;
}
i++;
}
for (i = 0; str[i] != 0; i++){
printf("'%c' : %dn", i + 'a', count[i]);
}
return 0;
}

如何看到所有的字母在字母表打印时运行这个?和for循环有关吗?

打印循环应该遍历count的索引。

for (i = 0; i < 26; i++){
printf("'%c' : %dn", i + 'a', count[i]);
}

最新更新