user-0 提问: 求解 我是c语言新手，分类排序。偶数从大到小排列 ，奇数从小到大排列

回复:
user: user-1
content: for(i=0;i<j-1;i++) for(x=i+1;x<m;x++) { if(b[i]>b[i+1]) { b[i]=b[i+1]; temp=b[i]; b[i+1]=temp; } } for(i=0;i<k;i++) for(x=i+1;x<m;x++) { if(c[i]<c[i+1]) { c[i]=c[i+1]; remp=c[i]; c[i+1]=remp; } 这一段没看懂 printf("%d\n%d\n",b,c); 这首要做啥？

user: user-2
content: #include <stdio.h> #include <stdlib.h> #include <string.h>   typedef int (*pfunc)(int );  int is_even(int num) {     return !(num % 2); }  int is_odd(int num) {     return (num % 2); }  void select_asc_sort(int *arr, int num, pfunc chk_func) {     int i, j;     int min, tmp;      for (i = 0; i < num; i++) {         if (!chk_func(arr[i]))             continue;         min = i;         for (j = i+1; j < num; j++) {             if (!chk_func(arr[j]))                 continue;             if (arr[min] > arr[j])                 min = j;         }         if (min != i) {             tmp = arr[min];             arr[min] = arr[i];             arr[i] = tmp;         }     } }  void bubble_asc_sort(int *arr, int num) {     int i, j;     int tmp;      for (i = 0; i < num; i++)         for (j = 0; j < num - i - 1; j++)             if (arr[j] > arr[j+1]) {                 tmp = arr[j];                 arr[j] = arr[j+1];                 arr[j+1] = tmp;             }  }  void print_arr(int *arr, int len) {     int i;      for (i = 0; i < len; i++)         printf("%d  ", arr[i]);     putchar(10); }  //#define BUBBLE_SORT  int main() {     int i, n, k, cnt;     char word[16];     int num[100], *arr = NULL;      while (scanf("%s", word) != EOF) {         printf("Please input the number of array: ");         scanf("%d", &n); #ifdef BUBBLE_SORT         arr = (int *)malloc(sizeof(int) * n);         if (!arr) {             fprintf(stderr, "malloc error!\n");             exit(1);         }         if(strcmp(word,"odd") == 0) {             printf("%s\n", word);              for (i = 0, cnt = 0; i < n; i++) {                 scanf("%d", &num[i]);                 if (is_odd(num[i]))                     arr[cnt++] = num[i];             }             bubble_sort(arr, cnt);             for (i = 0, k = 0; k < cnt && i < n; i++)                 if (is_odd(num[i]))                     num[i] = arr[k++];             free(arr);         } else if (strcmp(word, "even") == 0) {             printf("%s\n", word);              for (i = 0, cnt = 0; i < n; i++) {                 scanf("%d", &num[i]);                 if (is_even(num[i]))                     arr[cnt++] = num[i];             }              bubble_sort(arr, cnt);              for (i = 0, k = 0; k < cnt && i < n; i++)                 if (is_even(num[i]))                     num[i] = arr[k++];             free(arr);         } #else         if(strcmp(word, "odd") == 0) {             printf("%s\n", word);             for (i = 0; i < n; i++)                 scanf("%d", &num[i]);             select_asc_sort(num, n, is_odd);         } else if (strcmp(word, "even") == 0) {             printf("%s\n", word);             for (i = 0; i < n; i++)                 scanf("%d", &num[i]);             select_asc_sort(num, n, is_even);         } #endif         printf("Show all numbers: \n");         print_arr(num, n);     }     return 0; }