質問編集履歴
2
やっと理解できました!ご指摘ありがとうございますm\(_ _\)m
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,83 +30,87 @@
|
|
30
30
|
|
31
31
|
****************************************************************************
|
32
32
|
|
33
|
-
`
|
33
|
+
```
|
34
34
|
|
35
|
-
|
35
|
+
#include<stdio.h>
|
36
36
|
|
37
|
+
#include<stdlib.h>
|
38
|
+
|
37
|
-
|
39
|
+
#include<string.h>
|
38
40
|
|
39
41
|
|
40
42
|
|
41
|
-
`typedef struct _LIST`{
|
42
43
|
|
44
|
+
|
45
|
+
typedef struct _LIST{
|
46
|
+
|
43
|
-
|
47
|
+
int key;
|
44
48
|
|
45
49
|
char name[100 +1];
|
46
50
|
|
47
|
-
struct _LIST *next;
|
51
|
+
struct _LIST *next;
|
48
52
|
|
49
|
-
}
|
53
|
+
}LIST;
|
50
54
|
|
51
55
|
|
52
56
|
|
53
|
-
|
57
|
+
struct LIST *input_str();
|
54
58
|
|
55
|
-
struct LIST *show_str();
|
59
|
+
struct LIST *show_str();
|
56
60
|
|
57
61
|
|
58
62
|
|
59
|
-
|
63
|
+
int main(void)
|
60
64
|
|
61
65
|
{
|
62
66
|
|
63
67
|
//まずはリスト構造体へ登録
|
64
68
|
|
65
|
-
|
69
|
+
input_str();
|
66
70
|
|
67
71
|
//次に参照
|
68
72
|
|
69
|
-
|
73
|
+
show_str();
|
70
74
|
|
71
75
|
|
72
76
|
|
73
|
-
|
77
|
+
return 0;
|
74
78
|
|
75
79
|
}
|
76
80
|
|
77
81
|
|
78
82
|
|
79
|
-
|
83
|
+
struct LIST *input_str()
|
80
84
|
|
81
85
|
{
|
82
86
|
|
83
|
-
|
87
|
+
LIST *head;
|
84
88
|
|
85
|
-
struct LIST *temp;
|
89
|
+
struct LIST *temp; //先頭ポインタの初期化
|
86
90
|
|
87
|
-
|
91
|
+
int tkey;
|
88
92
|
|
89
|
-
char tname[100+1];
|
93
|
+
char tname[100+1];
|
90
94
|
|
91
|
-
|
95
|
+
int i;** //入力繰り返し判定用
|
92
96
|
|
93
97
|
|
94
98
|
|
95
99
|
//head->dummy用構造体の作成
|
96
100
|
|
97
|
-
|
101
|
+
if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) { //error
|
98
102
|
|
99
|
-
|
103
|
+
printf("malloc error\n");
|
100
104
|
|
101
|
-
exit(EXIT_FAILURE);
|
105
|
+
exit(EXIT_FAILURE);
|
102
106
|
|
103
|
-
|
107
|
+
}
|
104
108
|
|
105
109
|
|
106
110
|
|
107
|
-
|
111
|
+
head->key = -99; //error
|
108
112
|
|
109
|
-
|
113
|
+
strcpy(head->name,"dummy"); //error
|
110
114
|
|
111
115
|
|
112
116
|
|
@@ -114,25 +118,25 @@
|
|
114
118
|
|
115
119
|
|
116
120
|
|
117
|
-
|
121
|
+
do{
|
118
122
|
|
119
|
-
|
123
|
+
LIST *tmp = head; //1回目のループにはdummy構造体のheadポインタが入っている
|
120
124
|
|
121
|
-
|
125
|
+
printf("番号:"); scanf("%d",&tkey);
|
122
126
|
|
123
|
-
|
127
|
+
printf("名前:"); scanf("%s",tname);
|
124
128
|
|
125
129
|
|
126
130
|
|
127
131
|
//一つの構造体の領域を確保!
|
128
132
|
|
129
|
-
|
133
|
+
if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) { //error
|
130
134
|
|
131
|
-
|
135
|
+
printf("malloc error\n");
|
132
136
|
|
133
|
-
exit(EXIT_FAILURE);
|
137
|
+
exit(EXIT_FAILURE);
|
134
138
|
|
135
|
-
|
139
|
+
}
|
136
140
|
|
137
141
|
|
138
142
|
|
@@ -142,23 +146,23 @@
|
|
142
146
|
|
143
147
|
//入力されたデータを構造体へ
|
144
148
|
|
145
|
-
|
149
|
+
head->key = tkey; //error
|
146
150
|
|
147
|
-
|
151
|
+
strcpy(head->name,tname); //error
|
148
152
|
|
149
|
-
|
153
|
+
head->next = tmp; //error
|
150
154
|
|
151
155
|
|
152
156
|
|
153
|
-
|
157
|
+
printf("繰り返し入力しますか? Yes(1)/NO(0):\n"); scanf("%d",&i);}}
|
154
158
|
|
155
159
|
|
156
160
|
|
157
|
-
|
161
|
+
}while(i == 1);
|
158
162
|
|
159
163
|
|
160
164
|
|
161
|
-
|
165
|
+
return (head);
|
162
166
|
|
163
167
|
|
164
168
|
|
@@ -168,12 +172,12 @@
|
|
168
172
|
|
169
173
|
|
170
174
|
|
171
|
-
|
175
|
+
struct LIST *show_str()
|
172
176
|
|
173
177
|
{
|
174
178
|
|
175
|
-
|
179
|
+
//未完成
|
176
180
|
|
177
181
|
}
|
178
182
|
|
179
|
-
|
183
|
+
```
|
1
ソースを書き直した方が綺麗になるんじゃないだろうかと思ったのですが、ありのーままでーハイライトしてみました。お願い致します。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,85 +30,83 @@
|
|
30
30
|
|
31
31
|
****************************************************************************
|
32
32
|
|
33
|
-
|
33
|
+
`#include<stdio.h>`
|
34
34
|
|
35
|
-
|
35
|
+
`#include<stdlib.h>`
|
36
36
|
|
37
|
-
|
37
|
+
`#include<string.h>`
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
typedef struct _LIST{
|
41
|
+
`typedef struct _LIST`{
|
42
42
|
|
43
|
-
int key;
|
43
|
+
**int key;
|
44
44
|
|
45
45
|
char name[100 +1];
|
46
46
|
|
47
|
-
struct _LIST *next;
|
47
|
+
struct _LIST *next;**
|
48
48
|
|
49
|
-
}LIST;
|
49
|
+
}`LIST`;
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
struct LIST *input_str();
|
53
|
+
**struct LIST *input_str();
|
54
54
|
|
55
|
-
struct LIST *show_str();
|
55
|
+
struct LIST *show_str();**
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
int main(void)
|
59
|
+
`int main(void)`
|
60
60
|
|
61
61
|
{
|
62
62
|
|
63
|
-
|
64
|
-
|
65
63
|
//まずはリスト構造体へ登録
|
66
64
|
|
67
|
-
input_str();
|
65
|
+
**input_str();**
|
68
66
|
|
69
67
|
//次に参照
|
70
68
|
|
71
|
-
show_str();
|
69
|
+
**show_str();**
|
72
70
|
|
73
71
|
|
74
72
|
|
75
|
-
return 0;
|
73
|
+
**return 0;**
|
76
74
|
|
77
75
|
}
|
78
76
|
|
79
77
|
|
80
78
|
|
81
|
-
struct LIST *input_str()
|
79
|
+
`struct LIST *input_str()`
|
82
80
|
|
83
81
|
{
|
84
82
|
|
85
|
-
LIST *head;
|
83
|
+
**LIST *head;
|
86
84
|
|
87
|
-
struct LIST *temp; //先頭ポインタの初期化
|
85
|
+
struct LIST *temp;** //先頭ポインタの初期化
|
88
86
|
|
89
|
-
int tkey;
|
87
|
+
**int tkey;
|
90
88
|
|
91
|
-
char tname[100+1];
|
89
|
+
char tname[100+1];**
|
92
90
|
|
93
|
-
int i; //入力繰り返し判定用
|
91
|
+
**int i;** //入力繰り返し判定用
|
94
92
|
|
95
93
|
|
96
94
|
|
97
95
|
//head->dummy用構造体の作成
|
98
96
|
|
99
|
-
if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) { //error
|
97
|
+
`if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) {` //error
|
100
98
|
|
101
|
-
printf("malloc error\n");
|
99
|
+
**printf("malloc error\n");
|
102
100
|
|
103
|
-
exit(EXIT_FAILURE);
|
101
|
+
exit(EXIT_FAILURE);**
|
104
102
|
|
105
|
-
}
|
103
|
+
`}`
|
106
104
|
|
107
105
|
|
108
106
|
|
109
|
-
head->key = -99; //error
|
107
|
+
**head->key = -99;** //error
|
110
108
|
|
111
|
-
strcpy(head->name,"dummy"); //error
|
109
|
+
**strcpy(head->name,"dummy");** //error
|
112
110
|
|
113
111
|
|
114
112
|
|
@@ -116,25 +114,25 @@
|
|
116
114
|
|
117
115
|
|
118
116
|
|
119
|
-
do{
|
117
|
+
`do{`
|
120
118
|
|
121
|
-
LIST *tmp = head; //1回目のループにはdummy構造体のheadポインタが入っている
|
119
|
+
**LIST *tmp = head;** //1回目のループにはdummy構造体のheadポインタが入っている
|
122
120
|
|
123
|
-
printf("番号:"); scanf("%d",&tkey);
|
121
|
+
**printf("番号:"); scanf("%d",&tkey);**
|
124
122
|
|
125
|
-
printf("名前:"); scanf("%s",tname);
|
123
|
+
**printf("名前:"); scanf("%s",tname);**
|
126
124
|
|
127
125
|
|
128
126
|
|
129
127
|
//一つの構造体の領域を確保!
|
130
128
|
|
131
|
-
if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) { //error
|
129
|
+
`if ((head = (LIST *) malloc(sizeof(LIST))) == NULL) {` //error
|
132
130
|
|
133
|
-
printf("malloc error\n");
|
131
|
+
**printf("malloc error\n");
|
134
132
|
|
135
|
-
exit(EXIT_FAILURE);
|
133
|
+
exit(EXIT_FAILURE);**
|
136
134
|
|
137
|
-
}
|
135
|
+
`}`
|
138
136
|
|
139
137
|
|
140
138
|
|
@@ -144,23 +142,23 @@
|
|
144
142
|
|
145
143
|
//入力されたデータを構造体へ
|
146
144
|
|
147
|
-
head->key = tkey; //error
|
145
|
+
**head->key = tkey;** //error
|
148
146
|
|
149
|
-
strcpy(head->name,tname); //error
|
147
|
+
**strcpy(head->name,tname);** //error
|
150
148
|
|
151
|
-
head->next = tmp; //error
|
149
|
+
**head->next = tmp;** //error
|
152
150
|
|
153
151
|
|
154
152
|
|
155
|
-
printf("繰り返し入力しますか? Yes(1)/NO(0):\n"); scanf("%d",&i);
|
153
|
+
**printf("繰り返し入力しますか? Yes(1)/NO(0):\n"); scanf("%d",&i);}}**
|
156
154
|
|
157
155
|
|
158
156
|
|
159
|
-
}while(i == 1);
|
157
|
+
`}while(i == 1);`
|
160
158
|
|
161
159
|
|
162
160
|
|
163
|
-
return (head);
|
161
|
+
**return (head);**
|
164
162
|
|
165
163
|
|
166
164
|
|
@@ -170,11 +168,11 @@
|
|
170
168
|
|
171
169
|
|
172
170
|
|
173
|
-
struct LIST *show_str()
|
171
|
+
`struct LIST *show_str()`
|
174
172
|
|
175
173
|
{
|
176
174
|
|
177
|
-
//未完成
|
175
|
+
**//未完成**
|
178
176
|
|
179
177
|
}
|
180
178
|
|