回答編集履歴
4
tfree 追加
test
CHANGED
@@ -82,6 +82,14 @@
|
|
82
82
|
return root;
|
83
83
|
}
|
84
84
|
|
85
|
+
void tfree(CELL *p) {
|
86
|
+
if(p == NULL) return;
|
87
|
+
|
88
|
+
tfree(p->right);
|
89
|
+
tfree(p->left);
|
90
|
+
free(p);
|
91
|
+
}
|
92
|
+
|
85
93
|
int input(char *buf) {
|
86
94
|
printf("\n単語, または00を入力して下さい(00なら終了します): ");
|
87
95
|
scanf("%s", buf);
|
@@ -102,6 +110,7 @@
|
|
102
110
|
}
|
103
111
|
printf("終了します.\n");
|
104
112
|
|
113
|
+
tfree(root);
|
105
114
|
exit(0);
|
106
115
|
}
|
107
116
|
```
|
3
大文字化で無く小文字化でした
test
CHANGED
@@ -67,7 +67,7 @@
|
|
67
67
|
char str[256];
|
68
68
|
while((c = fgetc(fp)) != EOF) {
|
69
69
|
if(c > ' ' && !strchr(SEPARATORS, c)) {
|
70
|
-
str[i++] = to
|
70
|
+
str[i++] = tolower(c);
|
71
71
|
str[i] = '\0';
|
72
72
|
continue;
|
73
73
|
}
|
@@ -110,60 +110,60 @@
|
|
110
110
|
**************************
|
111
111
|
入力ファイル名: test.txt
|
112
112
|
|
113
|
-
|
113
|
+
section
|
114
114
|
1
|
115
|
-
|
115
|
+
full
|
116
|
-
|
116
|
+
faith
|
117
|
-
|
117
|
+
and
|
118
|
-
|
118
|
+
credit
|
119
|
-
|
119
|
+
shall
|
120
|
-
|
120
|
+
be
|
121
|
-
|
121
|
+
given
|
122
|
-
|
122
|
+
in
|
123
123
|
:
|
124
124
|
(中略)
|
125
125
|
:
|
126
|
-
|
126
|
+
be
|
127
|
-
|
127
|
+
removed
|
128
|
-
|
128
|
+
to
|
129
|
-
|
129
|
+
the
|
130
|
-
|
130
|
+
state
|
131
|
-
|
131
|
+
having
|
132
|
-
|
132
|
+
jurisdiction
|
133
|
-
|
133
|
+
of
|
134
|
-
|
134
|
+
the
|
135
|
-
|
135
|
+
crime
|
136
136
|
*** 単語の出現頻度 ***
|
137
137
|
1 1
|
138
138
|
1 2
|
139
|
-
1
|
139
|
+
1 a
|
140
|
-
2
|
140
|
+
2 acts
|
141
|
-
1
|
141
|
+
1 all
|
142
|
-
7
|
142
|
+
7 and
|
143
|
-
1
|
143
|
+
1 another
|
144
|
-
1
|
144
|
+
1 any
|
145
|
-
1
|
145
|
+
1 authority
|
146
|
-
6
|
146
|
+
6 be
|
147
147
|
:
|
148
148
|
(中略)
|
149
149
|
:
|
150
|
-
1
|
150
|
+
1 states
|
151
|
-
1
|
151
|
+
1 such
|
152
|
-
10
|
152
|
+
10 the
|
153
|
-
1
|
153
|
+
1 thereof
|
154
|
-
4
|
154
|
+
4 to
|
155
|
-
1
|
155
|
+
1 treason
|
156
|
-
1
|
156
|
+
1 up
|
157
|
-
2
|
157
|
+
2 which
|
158
|
-
1
|
158
|
+
1 who
|
159
|
-
1
|
159
|
+
1 with
|
160
160
|
68種類の単語を登録
|
161
161
|
|
162
|
-
単語, または00を入力して下さい(00なら終了します):
|
162
|
+
単語, または00を入力して下さい(00なら終了します): the
|
163
|
-
|
163
|
+
theの出現頻度: 10
|
164
164
|
|
165
|
-
単語, または00を入力して下さい(00なら終了します):
|
165
|
+
単語, または00を入力して下さい(00なら終了します): abc
|
166
|
-
|
166
|
+
abcの単語は登録されていません!
|
167
167
|
|
168
168
|
単語, または00を入力して下さい(00なら終了します): 00
|
169
169
|
終了します.
|
2
toupper を利用
test
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
#include <stdio.h>
|
3
3
|
#include <stdlib.h>
|
4
4
|
#include <string.h>
|
5
|
+
#include <ctype.h>
|
5
6
|
|
6
7
|
#define SEPARATORS ",.':;()"
|
7
8
|
|
@@ -66,8 +67,7 @@
|
|
66
67
|
char str[256];
|
67
68
|
while((c = fgetc(fp)) != EOF) {
|
68
69
|
if(c > ' ' && !strchr(SEPARATORS, c)) {
|
69
|
-
if('a' <= c && c <= 'z') c -= 'a' - 'A';
|
70
|
-
str[i++] = c;
|
70
|
+
str[i++] = toupper(c);
|
71
71
|
str[i] = '\0';
|
72
72
|
continue;
|
73
73
|
}
|
1
修正
test
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
|
26
26
|
int a = strcmp(name, p->key);
|
27
27
|
if(a == 0) {
|
28
|
-
p->count +
|
28
|
+
p->count ++;
|
29
29
|
} else {
|
30
30
|
CELL **q = TBRANCH(a, p);
|
31
31
|
*q = tinsert(*q, name);
|