Andziev

Порамнување

Jan 8th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int switcher (int number) {
  4.     if(number == 0)
  5.         return 0;
  6.     if(number%10 == 9)
  7.         return 7 + 10 * switcher (number/10);
  8.     else
  9.         return number%10 + 10 * switcher (number/10);
  10. }
  11.  
  12. int sort (int array[], int N) {
  13.     for(int i=0; i<N; i++) {
  14.         for(int j=0; j<N-1; j++) {
  15.             if(array[j] > array[j+1]) {
  16.                 int temp = array[j];
  17.                 array[j] = array[j+1];
  18.                 array[j+1] = temp;
  19.             }
  20.         }
  21.     }
  22. }
  23.  
  24. int print (int array[], int N) {
  25.     int size = 5;
  26.     if(N < 5)
  27.         size = N;
  28.  
  29.     for(int i=0; i<size; i++)
  30.         printf("%d ",array[i]);
  31. }
  32.  
  33. int main () {
  34.     int array [100], number, N = 0;
  35.     while(scanf("%d",&number)) {
  36.         array[N++] = switcher(number);
  37.     }
  38.     sort(array,N);
  39.     print(array,N);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment