Advertisement
anhkiet2507

SapXepChanLe-AC

May 10th, 2021
2,494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include<stdio.h>
  2. const int MAX = 100;
  3. int main(){
  4.     int n,i,j,t;
  5.     int a[MAX];
  6.     scanf("%d", &n);
  7.     for(i = 0; i < n; i++){
  8.         scanf("%d", &a[i]);
  9.     }
  10.     for(i = 0; i < n ; i++){
  11.         for ( j = i + 1; j < n; j++){
  12.             if(a[i]>a[j]){
  13.                 t = a[i];
  14.                 a[i]=a[j];
  15.                 a[j]=t;
  16.             }
  17.         }
  18.     }
  19.     for(i = 0; i <n; i++){
  20.         if(a[i]%2==0){
  21.             printf("%d ", a[i]);
  22.         }
  23.     }
  24.     for(i = 0; i <n; i++){
  25.         if(a[i]%2!=0){
  26.             printf("%d ", a[i]);
  27.         }
  28.     }
  29.     return 0;  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement