回答編集履歴
1
ソースの追加
test
CHANGED
@@ -64,6 +64,8 @@
|
|
64
64
|
|
65
65
|
}
|
66
66
|
|
67
|
+
printf("\n");
|
68
|
+
|
67
69
|
printf("3の倍数以外");
|
68
70
|
|
69
71
|
for(i = 0; i < MAX_NUMBER; i++){
|
@@ -81,3 +83,103 @@
|
|
81
83
|
}
|
82
84
|
|
83
85
|
```
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
### 追記
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
どこが原因かわかりました。とりあえず、以下のソースで試してください。
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```C
|
98
|
+
|
99
|
+
#include <stdio.h>
|
100
|
+
|
101
|
+
#include <stdlib.h>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
#define BUFSIZE 256
|
106
|
+
|
107
|
+
#define MAX_NUMBER 10
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
int main(void)
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
char buf[BUFSIZE];
|
116
|
+
|
117
|
+
int data[MAX_NUMBER];
|
118
|
+
|
119
|
+
int i;
|
120
|
+
|
121
|
+
int a[MAX_NUMBER];
|
122
|
+
|
123
|
+
int b[MAX_NUMBER];
|
124
|
+
|
125
|
+
int count = 0;
|
126
|
+
|
127
|
+
int count2 = 0;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
for(i = 0; i < MAX_NUMBER; i++){
|
132
|
+
|
133
|
+
fgets(buf,sizeof(buf),stdin);
|
134
|
+
|
135
|
+
data[i] = atoi(buf);
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
for(i = 0; i < MAX_NUMBER; i++){
|
142
|
+
|
143
|
+
if(data[i] % 3 == 0){
|
144
|
+
|
145
|
+
a[count] = data[i];
|
146
|
+
|
147
|
+
count++;
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
else{
|
152
|
+
|
153
|
+
b[count2] = data[i];
|
154
|
+
|
155
|
+
count2++;
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
printf("3の倍数:");
|
162
|
+
|
163
|
+
for(i = 0; i < count; i++){
|
164
|
+
|
165
|
+
printf("%d ",a[i]);
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
printf("\n");
|
170
|
+
|
171
|
+
printf("3の倍数以外:");
|
172
|
+
|
173
|
+
for(i = 0; i < count2; i++){
|
174
|
+
|
175
|
+
printf("%d ",b[i]);
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
return 0;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
```
|