Guest User

Untitled

a guest
Feb 11th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int N,K;
  6.     scanf("%d%d",&N,&K);
  7.     int A[N],B[N];
  8.     for (int i=0; i<N; i++){
  9.         cin >> A[i];
  10.         if (A[i] % K < A[i+1] % K){
  11.             swap(A[i],A[i+1]);
  12.         }
  13.     }
  14.     for (int i=0; i<N; i++){
  15.         cout << A[i] << " ";
  16.     }
  17.  
  18. }
Add Comment
Please, Sign In to add comment