#include <stdio.h>
int main() {
int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int even[10], odd[10];
int loop, e, d;
e = d = 0;
for(loop = 0; loop < 10; loop++) {
if(array[loop]%2 == 0) {
even[e] = array[loop];
e++;
} else {
odd[d] = array[loop];
d++;
}
}
printf(" original -> ");
for(loop = 0; loop < 10; loop++)
printf(" %d", array[loop]);
printf("/n even -> ");
for(loop = 0; loop < e; loop++)
printf(" %d", even[loop]);
printf("/n odd -> ");
for(loop = 0; loop < d; loop++)
printf(" %d", odd[loop]);
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265343.html