質問編集履歴
6
意図的に内容を抹消する行為にあたるため
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,395 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
#include <stdio.h>
|
4
|
+
|
5
|
+
#include <string.h>
|
6
|
+
|
7
|
+
#include <stdlib.h>
|
8
|
+
|
9
|
+
#include <limits.h>
|
10
|
+
|
11
|
+
#define MAX 10
|
12
|
+
|
13
|
+
#define NAME_LEN 20
|
14
|
+
|
15
|
+
/*--- 身体データ型 ---*/
|
16
|
+
|
17
|
+
typedef struct{
|
18
|
+
|
19
|
+
int height; /* 身長 */
|
20
|
+
|
21
|
+
double vision; /* 視力 */
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
Body ;
|
26
|
+
|
27
|
+
/*--- 身体検査データ型 ---*/
|
28
|
+
|
29
|
+
typedef struct{
|
30
|
+
|
31
|
+
char *name; /* 氏名 */
|
32
|
+
|
1
|
-
|
33
|
+
Body body; /* 身体データ型 ---*/
|
34
|
+
|
35
|
+
} PhysCheck ;
|
36
|
+
|
37
|
+
/*--- 身体検査データ型スタックを実現する構造体 ---*/
|
38
|
+
|
39
|
+
typedef struct {
|
40
|
+
|
41
|
+
int max; /* スタックの容量 */
|
42
|
+
|
43
|
+
int ptr; /* スタックポインタ */
|
44
|
+
|
45
|
+
char **que; /* スタック本体(char* へのポインタ配列 )*/
|
46
|
+
|
47
|
+
} PhysCheckStack;
|
48
|
+
|
49
|
+
/*--- キューを実現する構造体 ---*/
|
50
|
+
|
51
|
+
typedef struct {
|
52
|
+
|
53
|
+
int max; /*キューの容量*/
|
54
|
+
|
55
|
+
int num; /*現在の要素数*/
|
56
|
+
|
57
|
+
int front; /*先頭要素のカーソル*/
|
58
|
+
|
59
|
+
int rear; /*末尾要素のカーソル*/
|
60
|
+
|
61
|
+
int *que; /*キュー本体*/
|
62
|
+
|
63
|
+
}IntQueue;
|
64
|
+
|
65
|
+
/*--- Boyer-Moore 法による文字列探索 ---*/
|
66
|
+
|
67
|
+
char *bm_match(char *pat , char *txt){
|
68
|
+
|
69
|
+
char *pt; /* txt をなぞるカーソル */
|
70
|
+
|
71
|
+
char *pp; /* pat をなぞるカーソル */
|
72
|
+
|
73
|
+
int txt_len = strlen(txt); /* txt の文字数 */
|
74
|
+
|
75
|
+
int pat_len = strlen(pat); /* pat の文字数 */
|
76
|
+
|
77
|
+
int skip[UCHAR_MAX + 1]; /* スキップテーブル */
|
78
|
+
|
79
|
+
int i;
|
80
|
+
|
81
|
+
for (i = 0; i <= UCHAR_MAX; i++) /* スキップテーブルの作成 */
|
82
|
+
|
83
|
+
skip[i] = pat_len;
|
84
|
+
|
85
|
+
for (pp = pat; *pp != '\0'; pp++)
|
86
|
+
|
87
|
+
skip[*pp] = strlen(pp) - 1;
|
88
|
+
|
89
|
+
skip[*(pp - 1)] = pat_len; /* パターンの最後文字の移動距離はパターンの文字数 */
|
90
|
+
|
91
|
+
pt = txt + pat_len - 1; /* pat の末尾と比較する txt の文字を決定 */
|
92
|
+
|
93
|
+
while ( pt < txt + txt_len) { /* txt の比較する文字の位置が txt の末尾を越えるまで */
|
94
|
+
|
95
|
+
pp = pat + pat_len - 1; /* pat の最後の文字に着目 */
|
96
|
+
|
97
|
+
while (*pt == *pp) {
|
98
|
+
|
99
|
+
if (pp == pat) return pt; /* 一致した文字がパターンの最初の文字になれば終了 */
|
100
|
+
|
101
|
+
pp--;
|
102
|
+
|
103
|
+
pt--;
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
pt += (skip[*pt]> strlen(pp)) ? skip[*pt] : strlen(pp);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
return NULL;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
/*--- キューの初期化 ---*/
|
116
|
+
|
117
|
+
int Initialize(IntQueue *q, int max){
|
118
|
+
|
119
|
+
q->num = q->front = q->rear =0;
|
120
|
+
|
121
|
+
if ((q->que = calloc(max, sizeof(int))) == NULL) { /*stk=que ?? char*=int ??*/
|
122
|
+
|
123
|
+
q->max = 0; /* 配列の確保に失敗 */
|
124
|
+
|
125
|
+
return -1;
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
/* 配列の確保に成功 */
|
130
|
+
|
131
|
+
q->max = max;
|
132
|
+
|
133
|
+
return 0;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
/*--- キューにデータをエンキュー ---*/
|
138
|
+
|
139
|
+
int Enque(IntQueue *q, int x){
|
140
|
+
|
141
|
+
if (q->num >= q->max)
|
142
|
+
|
143
|
+
return -1; /* スタック満杯 */
|
144
|
+
|
145
|
+
else{
|
146
|
+
|
147
|
+
q->num++;
|
148
|
+
|
149
|
+
q->que[q->rear++] = x;
|
150
|
+
|
151
|
+
if(q->rear == q->max)
|
152
|
+
|
153
|
+
q->rear = 0;
|
154
|
+
|
155
|
+
return 0;
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
/*---キューからデータをデキュー ---*/
|
162
|
+
|
163
|
+
int Deque(IntQueue *q, int *x){
|
164
|
+
|
165
|
+
if (q->num <= 0)
|
166
|
+
|
167
|
+
return -1; /* キューは空 */
|
168
|
+
|
169
|
+
else{
|
170
|
+
|
171
|
+
q->num--;
|
172
|
+
|
173
|
+
*x = q->que[q->front++];
|
174
|
+
|
175
|
+
if(q->front == q->max)
|
176
|
+
|
177
|
+
q->front = 0;
|
178
|
+
|
179
|
+
return 0;
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
/*--- キューからデータをピーク ---*/
|
186
|
+
|
187
|
+
int Peek(const IntQueue *q, int *x){
|
188
|
+
|
189
|
+
if (q->num <= 0)
|
190
|
+
|
191
|
+
return -1;
|
192
|
+
|
193
|
+
*x = q->que[q->front];
|
194
|
+
|
195
|
+
return 0;
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
/*--- キューの容量 ---*/
|
200
|
+
|
201
|
+
int Capacity(const IntQueue *q){
|
202
|
+
|
203
|
+
return q->max;
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
/*--- キューに積まれているデータ数 ---*/
|
208
|
+
|
209
|
+
int Size(const IntQueue *q){
|
210
|
+
|
211
|
+
return q->num;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
/*--- 身体検査データを1つ表示 ---*/
|
216
|
+
|
217
|
+
void OneDataPrint(const IntQueue *q){ ➀
|
218
|
+
|
219
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision); ➁
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
/*--- キューの全データの表示 ---*/
|
224
|
+
|
225
|
+
void Print(const IntQueue *q){
|
226
|
+
|
227
|
+
int i;
|
228
|
+
|
229
|
+
for(i = 0; i < q->num; i++)
|
230
|
+
|
231
|
+
OneDataPrint(q->que+i);
|
232
|
+
|
233
|
+
putchar('\n');
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
/*--- スタックのデータにあるパターンの表示とその数を数える ---*/
|
238
|
+
|
239
|
+
int Search(IntQueue *q, int x){
|
240
|
+
|
241
|
+
int i, last, num = 0;
|
242
|
+
|
243
|
+
char *txt, *pat = x->name; ➂
|
244
|
+
|
245
|
+
for(i = 0; i < q->num; i++){ /* 底から頂上へ */
|
246
|
+
|
247
|
+
txt = q->que[i].name;
|
248
|
+
|
249
|
+
while((txt = bm_match(pat, txt)) != NULL){
|
250
|
+
|
251
|
+
num ++;
|
252
|
+
|
253
|
+
txt ++; last = i;
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
if (num > 0) OneDataPrint(q->que + last);
|
260
|
+
|
261
|
+
return num;
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
int main(void){
|
266
|
+
|
267
|
+
IntQueue que;
|
268
|
+
|
269
|
+
if(Initialize(&que, MAX)== -1){
|
270
|
+
|
271
|
+
puts("キューの生成に失敗しました。");
|
272
|
+
|
273
|
+
return 1;
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
Initialize(&s, MAX);
|
278
|
+
|
279
|
+
while (1) {
|
280
|
+
|
281
|
+
int menu, num;
|
282
|
+
|
283
|
+
printf("現在のデータ数:%d/%d\n",Size(&que), Capacity(&que));
|
284
|
+
|
285
|
+
printf("(1) エンキュー (2)デキュー (3) ピーク (4) 表示 (5)探索 (0) 終了:");
|
286
|
+
|
287
|
+
scanf("%d", &menu);
|
288
|
+
|
289
|
+
if (menu == 0) break;
|
290
|
+
|
291
|
+
switch (menu) {
|
292
|
+
|
293
|
+
case 1: /* エンキュー */
|
294
|
+
|
295
|
+
printf("名前: "); scanf("%s", x.name);
|
296
|
+
|
297
|
+
printf("身長: "); scanf("%d", &(x.body.height));
|
298
|
+
|
299
|
+
printf("視力: "); scanf("%lf", &(x.body.vision));
|
300
|
+
|
301
|
+
if (Enque(&que, x) == -1)
|
302
|
+
|
303
|
+
puts("\a エラー:エンキューに失敗しました。\n");
|
304
|
+
|
305
|
+
break;
|
306
|
+
|
307
|
+
case 2: /* デキュー */
|
308
|
+
|
309
|
+
if (Deque(&que, &x) == -1)
|
310
|
+
|
311
|
+
puts("\a エラー:デキューに失敗しました。\n");
|
312
|
+
|
313
|
+
else{
|
314
|
+
|
315
|
+
printf("デキューしたデータは,");
|
316
|
+
|
317
|
+
OneDataPrint(&x);
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
break;
|
322
|
+
|
323
|
+
case 3: /* ピーク */
|
324
|
+
|
325
|
+
if (Peek(&que, &x) == -1)
|
326
|
+
|
327
|
+
puts("\a エラー:ピークに失敗しました。\n");
|
328
|
+
|
329
|
+
else{
|
330
|
+
|
331
|
+
printf("ピークしたデータは,");
|
332
|
+
|
333
|
+
OneDataPrint(&x);
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
break;
|
338
|
+
|
339
|
+
case 4: /* 表示 */
|
340
|
+
|
341
|
+
Print(&que);
|
342
|
+
|
343
|
+
break;
|
344
|
+
|
345
|
+
case 5: /* 検索 */
|
346
|
+
|
347
|
+
printf("探す名前:"); scanf("%s", x.name);
|
348
|
+
|
349
|
+
if ((num = Search(&que, &x)) >0)
|
350
|
+
|
351
|
+
printf("名前に含まれるパターン数は,%d 個です,\n",num);
|
352
|
+
|
353
|
+
else{
|
354
|
+
|
355
|
+
puts("\a エラー:パターンは存在しません。\n ");
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
break;
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
Terminate(&que);
|
366
|
+
|
367
|
+
return 0;
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
```
|
372
|
+
|
373
|
+
動的スタックのプログラムを,動的なキューに変更したプログラムに変更したく上記のように書き換えたのですが、➀➁➂でエラーが生じてしまいます。解決方法が分からないです。
|
374
|
+
|
375
|
+
①でのエラーは
|
376
|
+
|
377
|
+
Main.c:110:35: note: passing argument to parameter 'q' here
|
378
|
+
|
379
|
+
②でのエラーは
|
380
|
+
|
381
|
+
Main.c:111:31: error: use of undeclared identifier 'x'
|
382
|
+
|
383
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
384
|
+
|
385
|
+
Main.c:111:39: error: use of undeclared identifier 'x'
|
386
|
+
|
387
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
388
|
+
|
389
|
+
Main.c:111:55: error: use of undeclared identifier 'x'
|
390
|
+
|
391
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
392
|
+
|
393
|
+
③でのエラーが
|
394
|
+
|
395
|
+
Main.c:124:23: error: member reference type 'int' is not a pointer char *txt, *pat = x->name;
|
5
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
4
qqqq
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,413 +1 @@
|
|
1
|
-
```ここに言語を入力
|
2
|
-
|
3
|
-
#include <stdio.h>
|
4
|
-
|
5
|
-
#include <string.h>
|
6
|
-
|
7
|
-
#include <stdlib.h>
|
8
|
-
|
9
|
-
#include <limits.h>
|
10
|
-
|
11
|
-
#define MAX 10
|
12
|
-
|
13
|
-
#define NAME_LEN 20
|
14
|
-
|
15
|
-
/*--- 身体データ型 ---*/
|
16
|
-
|
17
|
-
typedef struct{
|
18
|
-
|
19
|
-
int height; /* 身長 */
|
20
|
-
|
21
|
-
double vision; /* 視力 */
|
22
|
-
|
23
|
-
}
|
24
|
-
|
25
|
-
Body ;
|
26
|
-
|
27
|
-
/*--- 身体検査データ型 ---*/
|
28
|
-
|
29
|
-
typedef struct{
|
30
|
-
|
31
|
-
char *name; /* 氏名 */
|
32
|
-
|
33
|
-
|
1
|
+
```ここに言語を入力jりゅrでぇrwffwfqfqgfwrくぁsxzc
|
34
|
-
|
35
|
-
} PhysCheck ;
|
36
|
-
|
37
|
-
/*--- 身体検査データ型スタックを実現する構造体 ---*/
|
38
|
-
|
39
|
-
typedef struct {
|
40
|
-
|
41
|
-
int max; /* スタックの容量 */
|
42
|
-
|
43
|
-
int ptr; /* スタックポインタ */
|
44
|
-
|
45
|
-
char **que; /* スタック本体(char* へのポインタ配列 )*/
|
46
|
-
|
47
|
-
} PhysCheckStack;
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
/*--- キューを実現する構造体 ---*/
|
52
|
-
|
53
|
-
typedef struct {
|
54
|
-
|
55
|
-
int max; /*キューの容量*/
|
56
|
-
|
57
|
-
int num; /*現在の要素数*/
|
58
|
-
|
59
|
-
int front; /*先頭要素のカーソル*/
|
60
|
-
|
61
|
-
int rear; /*末尾要素のカーソル*/
|
62
|
-
|
63
|
-
int *que; /*キュー本体*/
|
64
|
-
|
65
|
-
}IntQueue;
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
/*--- Boyer-Moore 法による文字列探索 ---*/
|
70
|
-
|
71
|
-
char *bm_match(char *pat , char *txt){
|
72
|
-
|
73
|
-
char *pt; /* txt をなぞるカーソル */
|
74
|
-
|
75
|
-
char *pp; /* pat をなぞるカーソル */
|
76
|
-
|
77
|
-
int txt_len = strlen(txt); /* txt の文字数 */
|
78
|
-
|
79
|
-
int pat_len = strlen(pat); /* pat の文字数 */
|
80
|
-
|
81
|
-
int skip[UCHAR_MAX + 1]; /* スキップテーブル */
|
82
|
-
|
83
|
-
int i;
|
84
|
-
|
85
|
-
for (i = 0; i <= UCHAR_MAX; i++) /* スキップテーブルの作成 */
|
86
|
-
|
87
|
-
skip[i] = pat_len;
|
88
|
-
|
89
|
-
for (pp = pat; *pp != '\0'; pp++)
|
90
|
-
|
91
|
-
skip[*pp] = strlen(pp) - 1;
|
92
|
-
|
93
|
-
skip[*(pp - 1)] = pat_len; /* パターンの最後文字の移動距離はパターンの文字数 */
|
94
|
-
|
95
|
-
pt = txt + pat_len - 1; /* pat の末尾と比較する txt の文字を決定 */
|
96
|
-
|
97
|
-
while ( pt < txt + txt_len) { /* txt の比較する文字の位置が txt の末尾を越えるまで */
|
98
|
-
|
99
|
-
pp = pat + pat_len - 1; /* pat の最後の文字に着目 */
|
100
|
-
|
101
|
-
while (*pt == *pp) {
|
102
|
-
|
103
|
-
if (pp == pat) return pt; /* 一致した文字がパターンの最初の文字になれば終了 */
|
104
|
-
|
105
|
-
pp--;
|
106
|
-
|
107
|
-
pt--;
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
pt += (skip[*pt]> strlen(pp)) ? skip[*pt] : strlen(pp);
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
return NULL;
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
/*--- キューの初期化 ---*/
|
120
|
-
|
121
|
-
int Initialize(IntQueue *q, int max){
|
122
|
-
|
123
|
-
q->num = q->front = q->rear =0;
|
124
|
-
|
125
|
-
if ((q->que = calloc(max, sizeof(int))) == NULL) { /*stk=que ?? char*=int ??*/
|
126
|
-
|
127
|
-
q->max = 0; /* 配列の確保に失敗 */
|
128
|
-
|
129
|
-
return -1;
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
/* 配列の確保に成功 */
|
134
|
-
|
135
|
-
q->max = max;
|
136
|
-
|
137
|
-
return 0;
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
/*--- キューにデータをエンキュー ---*/
|
142
|
-
|
143
|
-
int Enque(IntQueue *q, int x){
|
144
|
-
|
145
|
-
if (q->num >= q->max)
|
146
|
-
|
147
|
-
return -1; /* スタック満杯 */
|
148
|
-
|
149
|
-
else{
|
150
|
-
|
151
|
-
q->num++;
|
152
|
-
|
153
|
-
q->que[q->rear++] = x;
|
154
|
-
|
155
|
-
if(q->rear == q->max)
|
156
|
-
|
157
|
-
q->rear = 0;
|
158
|
-
|
159
|
-
return 0;
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
/*---キューからデータをデキュー ---*/
|
166
|
-
|
167
|
-
int Deque(IntQueue *q, int *x){
|
168
|
-
|
169
|
-
if (q->num <= 0)
|
170
|
-
|
171
|
-
return -1; /* キューは空 */
|
172
|
-
|
173
|
-
else{
|
174
|
-
|
175
|
-
q->num--;
|
176
|
-
|
177
|
-
*x = q->que[q->front++];
|
178
|
-
|
179
|
-
if(q->front == q->max)
|
180
|
-
|
181
|
-
q->front = 0;
|
182
|
-
|
183
|
-
return 0;
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
/*--- キューからデータをピーク ---*/
|
190
|
-
|
191
|
-
int Peek(const IntQueue *q, int *x){
|
192
|
-
|
193
|
-
if (q->num <= 0)
|
194
|
-
|
195
|
-
return -1;
|
196
|
-
|
197
|
-
*x = q->que[q->front];
|
198
|
-
|
199
|
-
return 0;
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
/*--- キューの容量 ---*/
|
204
|
-
|
205
|
-
int Capacity(const IntQueue *q){
|
206
|
-
|
207
|
-
return q->max;
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
/*--- キューに積まれているデータ数 ---*/
|
212
|
-
|
213
|
-
int Size(const IntQueue *q){
|
214
|
-
|
215
|
-
return q->num;
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
/*--- 身体検査データを1つ表示 ---*/
|
220
|
-
|
221
|
-
void OneDataPrint(const IntQueue *q){ ➀
|
222
|
-
|
223
|
-
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision); ➁
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
/*--- キューの全データの表示 ---*/
|
228
|
-
|
229
|
-
void Print(const IntQueue *q){
|
230
|
-
|
231
|
-
int i;
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
for(i = 0; i < q->num; i++)
|
236
|
-
|
237
|
-
OneDataPrint(q->que+i);
|
238
|
-
|
239
|
-
putchar('\n');
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
/*--- スタックのデータにあるパターンの表示とその数を数える ---*/
|
244
|
-
|
245
|
-
int Search(IntQueue *q, int x){
|
246
|
-
|
247
|
-
int i, last, num = 0;
|
248
|
-
|
249
|
-
char *txt, *pat = x->name; ➂
|
250
|
-
|
251
|
-
for(i = 0; i < q->num; i++){ /* 底から頂上へ */
|
252
|
-
|
253
|
-
txt = q->que[i].name;
|
254
|
-
|
255
|
-
while((txt = bm_match(pat, txt)) != NULL){
|
256
|
-
|
257
|
-
num ++;
|
258
|
-
|
259
|
-
txt ++; last = i;
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
if (num > 0) OneDataPrint(q->que + last);
|
266
|
-
|
267
|
-
return num;
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
int main(void){
|
272
|
-
|
273
|
-
IntQueue que;
|
274
|
-
|
275
|
-
if(Initialize(&que, MAX)== -1){
|
276
|
-
|
277
|
-
puts("キューの生成に失敗しました。");
|
278
|
-
|
279
|
-
return 1;
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
Initialize(&s, MAX);
|
284
|
-
|
285
|
-
while (1) {
|
286
|
-
|
287
|
-
int menu, num;
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
printf("現在のデータ数:%d/%d\n",Size(&que), Capacity(&que));
|
292
|
-
|
293
|
-
printf("(1) エンキュー (2)デキュー (3) ピーク (4) 表示 (5)探索 (0) 終了:");
|
294
|
-
|
295
|
-
scanf("%d", &menu);
|
296
|
-
|
297
|
-
if (menu == 0) break;
|
298
|
-
|
299
|
-
switch (menu) {
|
300
|
-
|
301
|
-
case 1: /* エンキュー */
|
302
|
-
|
303
|
-
printf("名前: "); scanf("%s", x.name);
|
304
|
-
|
305
|
-
printf("身長: "); scanf("%d", &(x.body.height));
|
306
|
-
|
307
|
-
printf("視力: "); scanf("%lf", &(x.body.vision));
|
308
|
-
|
309
|
-
if (Enque(&que, x) == -1)
|
310
|
-
|
311
|
-
puts("\a エラー:エンキューに失敗しました。\n");
|
312
|
-
|
313
|
-
break;
|
314
|
-
|
315
|
-
case 2: /* デキュー */
|
316
|
-
|
317
|
-
if (Deque(&que, &x) == -1)
|
318
|
-
|
319
|
-
puts("\a エラー:デキューに失敗しました。\n");
|
320
|
-
|
321
|
-
else{
|
322
|
-
|
323
|
-
printf("デキューしたデータは,");
|
324
|
-
|
325
|
-
OneDataPrint(&x);
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
break;
|
330
|
-
|
331
|
-
case 3: /* ピーク */
|
332
|
-
|
333
|
-
if (Peek(&que, &x) == -1)
|
334
|
-
|
335
|
-
puts("\a エラー:ピークに失敗しました。\n");
|
336
|
-
|
337
|
-
else{
|
338
|
-
|
339
|
-
printf("ピークしたデータは,");
|
340
|
-
|
341
|
-
OneDataPrint(&x);
|
342
|
-
|
343
|
-
}
|
344
|
-
|
345
|
-
break;
|
346
|
-
|
347
|
-
case 4: /* 表示 */
|
348
|
-
|
349
|
-
Print(&que);
|
350
|
-
|
351
|
-
break;
|
352
|
-
|
353
|
-
case 5: /* 検索 */
|
354
|
-
|
355
|
-
printf("探す名前:"); scanf("%s", x.name);
|
356
|
-
|
357
|
-
if ((num = Search(&que, &x)) >0)
|
358
|
-
|
359
|
-
printf("名前に含まれるパターン数は,%d 個です,\n",num);
|
360
|
-
|
361
|
-
else{
|
362
|
-
|
363
|
-
puts("\a エラー:パターンは存在しません。\n ");
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
break;
|
368
|
-
|
369
|
-
}
|
370
|
-
|
371
|
-
}
|
372
|
-
|
373
|
-
Terminate(&que);
|
374
|
-
|
375
|
-
return 0;
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
```
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
動的スタックのプログラムを,動的なキューに変更したプログラムに変更したく上記のように書き換えたのですが、➀➁➂でエラーが生じてしまいます。解決方法が分からないです。
|
386
|
-
|
387
|
-
①でのエラーは
|
388
|
-
|
389
|
-
Main.c:110:35: note: passing argument to parameter 'q' here
|
390
|
-
|
391
|
-
②でのエラーは
|
392
|
-
|
393
|
-
Main.c:111:31: error: use of undeclared identifier 'x'
|
394
|
-
|
395
|
-
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
Main.c:111:39: error: use of undeclared identifier 'x'
|
400
|
-
|
401
|
-
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
Main.c:111:55: error: use of undeclared identifier 'x'
|
406
|
-
|
407
|
-
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
③でのエラーが
|
412
|
-
|
413
|
-
Main.c:124:23: error: member reference type 'int' is not a pointer char *txt, *pat = x->name;
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
```ここに言語を入力
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
#include <stdio.h>
|
6
4
|
|
7
5
|
#include <string.h>
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -385,3 +385,31 @@
|
|
385
385
|
|
386
386
|
|
387
387
|
動的スタックのプログラムを,動的なキューに変更したプログラムに変更したく上記のように書き換えたのですが、➀➁➂でエラーが生じてしまいます。解決方法が分からないです。
|
388
|
+
|
389
|
+
①でのエラーは
|
390
|
+
|
391
|
+
Main.c:110:35: note: passing argument to parameter 'q' here
|
392
|
+
|
393
|
+
②でのエラーは
|
394
|
+
|
395
|
+
Main.c:111:31: error: use of undeclared identifier 'x'
|
396
|
+
|
397
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
Main.c:111:39: error: use of undeclared identifier 'x'
|
402
|
+
|
403
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
Main.c:111:55: error: use of undeclared identifier 'x'
|
408
|
+
|
409
|
+
printf("%-18.18s%4d%5.1f\n", x->que, x->body.height, x-> body.vision);
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
③でのエラーが
|
414
|
+
|
415
|
+
Main.c:124:23: error: member reference type 'int' is not a pointer char *txt, *pat = x->name;
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
#include <stdio.h>
|
2
6
|
|
3
7
|
#include <string.h>
|
@@ -376,6 +380,8 @@
|
|
376
380
|
|
377
381
|
|
378
382
|
|
383
|
+
```
|
384
|
+
|
379
385
|
|
380
386
|
|
381
387
|
動的スタックのプログラムを,動的なキューに変更したプログラムに変更したく上記のように書き換えたのですが、➀➁➂でエラーが生じてしまいます。解決方法が分からないです。
|