質問編集履歴
4
情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,6 +46,8 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
+
またsort内で書くものがわからない
|
50
|
+
|
49
51
|
|
50
52
|
|
51
53
|
|
@@ -208,7 +210,7 @@
|
|
208
210
|
|
209
211
|
|
210
212
|
|
211
|
-
|
213
|
+
|
212
214
|
|
213
215
|
|
214
216
|
|
3
修正依頼
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,142 +56,146 @@
|
|
56
56
|
|
57
57
|
コード C
|
58
58
|
|
59
|
+
|
60
|
+
|
61
|
+
#include <stdio.h>
|
62
|
+
|
63
|
+
#include <stdlib.h>
|
64
|
+
|
65
|
+
#define MAX 10
|
66
|
+
|
67
|
+
#define FALSE 0
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
int input(FILE *in, int s[]);
|
72
|
+
|
73
|
+
int output(int s[], FILE *out);
|
74
|
+
|
75
|
+
void sort(int data[]);
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
int main(int argc, char *argv[]) {
|
80
|
+
|
81
|
+
int i;
|
82
|
+
|
83
|
+
int capa = 0;
|
84
|
+
|
85
|
+
FILE *nm1, *nm2;
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
if ((nm1 = fopen(argv[1], "r")) == NULL) {
|
90
|
+
|
91
|
+
fprintf(stderr, "Can't open input file.");
|
92
|
+
|
93
|
+
return -1;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
if ((nm2 = fopen(argv[2], "w")) == NULL) {
|
98
|
+
|
99
|
+
fprintf(stderr, "Can't open output file.");
|
100
|
+
|
101
|
+
return -1;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
fscanf(nm1, "%d", &capa);
|
106
|
+
|
107
|
+
int* number = (int*) malloc(sizeof(int*) * (capa));
|
108
|
+
|
109
|
+
for (i = 0; i < capa; i++) {
|
110
|
+
|
111
|
+
input(nm1, &number[i]);
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
sort(number);
|
116
|
+
|
117
|
+
for (i = 0; i < capa; i++) {
|
118
|
+
|
119
|
+
output(&number[i], nm2);
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
return 0;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
int input(FILE *in, int *s) {
|
130
|
+
|
131
|
+
if ((fscanf(in, "%d", s)) == '\0') {
|
132
|
+
|
133
|
+
return -1;
|
134
|
+
|
135
|
+
} else {
|
136
|
+
|
137
|
+
return 0;
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
void sort(int data[]) {
|
146
|
+
|
147
|
+
int i = 1;
|
148
|
+
|
149
|
+
while (FALSE) {
|
150
|
+
|
151
|
+
int count = 0;
|
152
|
+
|
153
|
+
if (data[i - 1] > data[i]) {
|
154
|
+
|
155
|
+
int j, tmp;
|
156
|
+
|
157
|
+
tmp = data[i];
|
158
|
+
|
159
|
+
for (j = 0; j < i; j++) {
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
if (count == 0)
|
168
|
+
|
169
|
+
break;
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
i++;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
int output(int s[], FILE *out) {
|
180
|
+
|
181
|
+
if ((fprintf(out, "%d\n", *s)) == '\0') {
|
182
|
+
|
183
|
+
return -1;
|
184
|
+
|
185
|
+
} else {
|
186
|
+
|
187
|
+
return 0;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
59
195
|
```
|
60
196
|
|
61
197
|
|
62
198
|
|
63
|
-
#include <stdio.h>
|
64
|
-
|
65
|
-
#include <stdlib.h>
|
66
|
-
|
67
|
-
#define MAX 10
|
68
|
-
|
69
|
-
#define FALSE 0
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
int input(FILE *in, int s[]);
|
74
|
-
|
75
|
-
int output(int s[], FILE *out);
|
76
|
-
|
77
|
-
void sort(int data[]);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
int main(int argc, char *argv[]) {
|
82
|
-
|
83
|
-
int i;
|
84
|
-
|
85
|
-
int capa = 0;
|
86
|
-
|
87
|
-
FILE *nm1, *nm2;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if ((nm1 = fopen(argv[1], "r")) == NULL) {
|
92
|
-
|
93
|
-
fprintf(stderr, "Can't open input file.");
|
94
|
-
|
95
|
-
return -1;
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
if ((nm2 = fopen(argv[2], "w")) == NULL) {
|
100
|
-
|
101
|
-
fprintf(stderr, "Can't open output file.");
|
102
|
-
|
103
|
-
return -1;
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
fscanf(nm1, "%d", &capa);
|
108
|
-
|
109
|
-
int* number = (int*) malloc(sizeof(int*) * (capa));
|
110
|
-
|
111
|
-
for (i = 0; i < capa; i++) {
|
112
|
-
|
113
|
-
input(nm1, &number[i]);
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
sort(number);
|
118
|
-
|
119
|
-
for (i = 0; i < capa; i++) {
|
120
|
-
|
121
|
-
output(&number[i], nm2);
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
return 0;
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
int input(FILE *in, int *s) {
|
132
|
-
|
133
|
-
if ((fscanf(in, "%d", s)) == '\0') {
|
134
|
-
|
135
|
-
return -1;
|
136
|
-
|
137
|
-
} else {
|
138
|
-
|
139
|
-
return 0;
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
void sort(int data[]) {
|
148
|
-
|
149
|
-
int i = 1;
|
150
|
-
|
151
|
-
while (FALSE) {
|
152
|
-
|
153
|
-
int count = 0;
|
154
|
-
|
155
|
-
if (data[i - 1] > data[i]) {
|
156
|
-
|
157
|
-
int j, tmp;
|
158
|
-
|
159
|
-
tmp = data[i];
|
160
|
-
|
161
|
-
for (j = 0; j < i; j++) {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
if (count == 0)
|
170
|
-
|
171
|
-
break;
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
i++;
|
176
|
-
|
177
|
-
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
int output(int s[], FILE *out) {
|
182
|
-
|
183
|
-
if ((fprintf(out, "%d\n", *s)) == '\0') {
|
184
|
-
|
185
|
-
return -1;
|
186
|
-
|
187
|
-
} else {
|
188
|
-
|
189
|
-
return 0;
|
190
|
-
|
191
|
-
}
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
199
|
|
196
200
|
|
197
201
|
```
|
2
修正依頼
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,6 +52,12 @@
|
|
52
52
|
|
53
53
|
### 該当のソースコード
|
54
54
|
|
55
|
+
```
|
56
|
+
|
57
|
+
コード C
|
58
|
+
|
59
|
+
```
|
60
|
+
|
55
61
|
|
56
62
|
|
57
63
|
#include <stdio.h>
|
@@ -188,6 +194,10 @@
|
|
188
194
|
|
189
195
|
|
190
196
|
|
197
|
+
```
|
198
|
+
|
199
|
+
|
200
|
+
|
191
201
|
|
192
202
|
|
193
203
|
### 試したこと
|
1
書式改善
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
C言語でソートができない
|
1
|
+
C言語でソートができない 挿入ソート
|
test
CHANGED
@@ -200,6 +200,4 @@
|
|
200
200
|
|
201
201
|
### 補足情報(FW/ツールのバージョンなど)
|
202
202
|
|
203
|
-
|
204
|
-
|
205
|
-
|
203
|
+
eclipse用いてます linuxです
|