質問編集履歴
1
補足
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
構造体
|
1
|
+
2つの構造体配列を比較しソート
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
signed int profit;
|
34
34
|
|
35
|
-
}person09;
|
35
|
+
}person09_t;
|
36
36
|
|
37
37
|
|
38
38
|
|
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
signed int profit;
|
44
44
|
|
45
|
-
}person10;
|
45
|
+
}person10_t;
|
46
46
|
|
47
47
|
|
48
48
|
|
@@ -92,75 +92,23 @@
|
|
92
92
|
|
93
93
|
char *result_array[8];
|
94
94
|
|
95
|
+
//char profit_array[8] = {0};
|
96
|
+
|
95
97
|
char *area;
|
96
98
|
|
97
99
|
int profit_d[8] = {0};
|
98
100
|
|
99
101
|
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
//構造体
|
103
|
+
//構造体配列
|
104
|
-
|
105
|
-
|
104
|
+
|
106
|
-
|
107
|
-
person10 data10[5];
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
//構造体初期化
|
114
|
-
|
115
|
-
data09[0].profit = 270;
|
116
|
-
|
117
|
-
data09[1].profit = 325;
|
118
|
-
|
119
|
-
data09[2].profit = 412;
|
120
|
-
|
121
|
-
data09[3].profit = 333;
|
122
|
-
|
123
|
-
data09[4].profit = 277;
|
124
|
-
|
125
|
-
data09[5].profit = 192;
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
strcpy(data09[0].name, "アトウ");
|
130
|
-
|
131
|
-
str
|
105
|
+
person09_t ary_09[6] = {{"アトウ",270},{"カスガ",325},{"タケモト",412},{"タナカ",333},{"ヤマシタ",277},{"ヨシオカ",192}};
|
132
|
-
|
133
|
-
|
106
|
+
|
134
|
-
|
135
|
-
strcpy(data09[3].name, "タナカ");
|
136
|
-
|
137
|
-
strcpy(data09[4].name, "ヤマシタ");
|
138
|
-
|
139
|
-
strcpy(data09[5].name, "ヨシオカ");
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
data10[0].profit = 357;
|
144
|
-
|
145
|
-
data10[1].profit = 210;
|
146
|
-
|
147
|
-
data10[2].profit = 445;
|
148
|
-
|
149
|
-
data10[3].profit = 233;
|
150
|
-
|
151
|
-
data10[4].profit = 145;
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
strcpy(data10[0].name, "カスガ");
|
156
|
-
|
157
|
-
str
|
107
|
+
person10_t ary_10[5] = {{"カスガ",357},{"スズキ",210},{"タケモト",445},{"ヤマシタ",233},{"ヨシダ",145}};
|
158
|
-
|
159
|
-
|
108
|
+
|
160
|
-
|
161
|
-
|
109
|
+
|
162
|
-
|
163
|
-
|
110
|
+
|
111
|
+
|
164
112
|
|
165
113
|
|
166
114
|
|
@@ -168,9 +116,9 @@
|
|
168
116
|
|
169
117
|
for( i=0 ; i < 6; i++){
|
170
118
|
|
171
|
-
printf("%s ",
|
119
|
+
printf("%s ",ary_09[i].name);
|
172
|
-
|
120
|
+
|
173
|
-
printf("%d\n",
|
121
|
+
printf("%d\n",ary_09[i].profit);
|
174
122
|
|
175
123
|
}
|
176
124
|
|
@@ -182,9 +130,9 @@
|
|
182
130
|
|
183
131
|
for( i=0 ; i < 5; i++){
|
184
132
|
|
185
|
-
printf("%s ",
|
133
|
+
printf("%s ",ary_10[i].name);
|
186
|
-
|
134
|
+
|
187
|
-
printf("%d\n",
|
135
|
+
printf("%d\n",ary_10[i].profit);
|
188
136
|
|
189
137
|
}
|
190
138
|
|
@@ -214,17 +162,17 @@
|
|
214
162
|
|
215
163
|
//売上比較
|
216
164
|
|
217
|
-
if(strcmp(
|
165
|
+
if(strcmp( ary_09[i].name, ary_10[j].name) == 0 ){
|
218
|
-
|
166
|
+
|
219
|
-
printf("%s ",
|
167
|
+
printf("%s ",ary_09[i].name);
|
220
|
-
|
168
|
+
|
221
|
-
profit_d[i] =
|
169
|
+
profit_d[i] = (ary_10[j].profit) - (ary_09[i].profit);
|
222
170
|
|
223
171
|
printf("%d\n",profit_d[i] );
|
224
172
|
|
225
173
|
flag[j] = CHECKED;
|
226
174
|
|
227
|
-
result_array[r] =
|
175
|
+
result_array[r] = ary_09[i].name;
|
228
176
|
|
229
177
|
r++;
|
230
178
|
|
@@ -242,9 +190,9 @@
|
|
242
190
|
|
243
191
|
if( cnt == RETIRE ){
|
244
192
|
|
245
|
-
printf("%s 退社\n",
|
193
|
+
printf("%s 退社\n",ary_09[i].name);
|
246
|
-
|
194
|
+
|
247
|
-
result_array[r] =
|
195
|
+
result_array[r] = ary_09[i].name;
|
248
196
|
|
249
197
|
r++;
|
250
198
|
|
@@ -264,9 +212,9 @@
|
|
264
212
|
|
265
213
|
if( flag[j] != CHECKED ){
|
266
214
|
|
267
|
-
printf("%s 入社\n",
|
215
|
+
printf("%s 入社\n",ary_10[j].name);
|
268
|
-
|
216
|
+
|
269
|
-
result_array[r] =
|
217
|
+
result_array[r] = ary_10[j].name;
|
270
218
|
|
271
219
|
r++;
|
272
220
|
|
@@ -276,8 +224,6 @@
|
|
276
224
|
|
277
225
|
|
278
226
|
|
279
|
-
|
280
|
-
|
281
227
|
//並び替え処理
|
282
228
|
|
283
229
|
printf("\n");
|
@@ -304,6 +250,14 @@
|
|
304
250
|
|
305
251
|
}
|
306
252
|
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
307
261
|
```
|
308
262
|
|
309
263
|
|
@@ -312,8 +266,6 @@
|
|
312
266
|
|
313
267
|
|
314
268
|
|
315
|
-
名前を50音順に並び替え、売り上げ、入社、退社
|
269
|
+
2つの構造体配列を比較し名前を50音順に並び替え、売り上げ、入社、退社 を名前と紐づけたいです。
|
316
|
-
|
317
|
-
|
318
270
|
|
319
271
|
何か良い方法があったら教えて頂きたいです。
|