-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch7-1.c
More file actions
49 lines (48 loc) · 855 Bytes
/
ch7-1.c
File metadata and controls
49 lines (48 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
struct T{
int c;
int n;
}cnt[127];
int main(){
char c;
int v[127]={0};
v[' ']=1;
v['\t']=1;
v['\n']=2;
cnt[1].n=0;
cnt[2].n=0;
int use=2;
while((c=getchar())!='#'){
// printf("read: %c\n", c);
if(v[c]==0){
use++;
// printf("new at %d\n", use);
cnt[use].c=c;
cnt[use].n=1;
v[c]=use;
} else {
cnt[v[c]].n++;
// printf("old at %d cnt = %d\n", v[c], cnt[v[c]].n);
}
}
printf("' '\t'\\n'\t");
for(int q=3;q<=8&&q<=use;q++){
printf("%c\t", cnt[q].c);
}
printf("\n");
printf("%d\t%d\t", cnt[1].n, cnt[2].n);
for(int q=3;q<=8&&q<=use;q++){
printf("%d\t", cnt[q].n);
}
printf("\n");
for(int q=9;q<=use;q+=8){
for(int w=q,e=1;w<=use&&e<=8;w++,e++){
printf("%c\t", cnt[w].c);
}
printf("\n");
for(int w=q,e=1;w<=use&&e<=8;w++,e++){
printf("%d\t", cnt[w].n);
}
printf("\n");
}
}