|
发表于 2018-1-21 23:46:50
|
显示全部楼层
本楼为最佳答案
你这代码还的确挺神的^_^
printf可以这样写,不过我认为这不是你想要的
- #include <stdio.h>
- #define num 128
- int main(void)
- {
- int ch;
- int ascii[num] = {0};
- while((ch = getchar()) != '\n')
- {
- ascii[ch]++;
- }
- for(int i = 0; i < num; ++i)
- {
- if(ascii[i] != 0)
- printf("%c: %d\n", i, ascii[i]);
- }
- return 0;
- }
复制代码
- Every orientation presupposes a disorientation
- : 4
- E: 1
- a: 3
- d: 1
- e: 5
- i: 5
- n: 4
- o: 5
- p: 3
- r: 4
- s: 4
- t: 4
- u: 1
- v: 1
- y: 1
- 请按任意键继续. . .
复制代码
我只知道输入了什么字母以及多少个,但并不知道顺序
所以没办法输出 Every orientation presupposes a disorientation |
|