我正在讀取輸入並嘗試以圖形格式打印所有輸入的小寫字符,能夠讀取它並記錄每個字符重複的次數但不記錄能夠以圖形方式打印它,可以幫助我。這裏是我的代碼讀取輸入字符並以圖形格式打印出現
#include <stdio.h>
#include <ctype.h>
int print_fun(int);
int main() {
int ch = 0, i = 0;
int char_count[26] = {0};
printf("\nNOTE:PRESS * TO EXIT\n");
while((ch = getchar()) != '*') {
if(islower(ch))
char_count[ch - 'a']++;
}
printf("\n");
for(i = 0; i < 26; i++)
//printf("%c:%d\n",'a'+ i, char_count[i]);
//printf("%c:\n", 'a'+ i, print_star(char_count[i]));
printf("%c:\n",print_star(char_count[i]),'a'+ i);
printf("\n");
return 0;
}
int print_star(int value) {
int i = 0;
for(i = 0; i < value; i++)
printf("*");
}
O/P:aaxyyz
a:**
b:
c:
...
...
x:*
y:**
z:*
請出示你將如何喜歡看一個例子。 「圖形方式」不是很有幫助。 –
@LayTaylor:我需要的o/p已經顯示 – user1985641