Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5.  
  6. #define DIM 5
  7.  
  8.  
  9. int * sort(int array[])
  10. {
  11.     for(int i = 0; i < DIM; i ++)
  12.     {
  13.         for(int j = 0; j < DIM - 1; j ++)
  14.         {
  15.             if(array[i] < array[j])
  16.             {
  17.                 int temp = array[i];
  18.                 array[i] = array[j];
  19.                 array[j] = temp;
  20.             }
  21.         }
  22.     }
  23.  
  24.  
  25.     return array;
  26. }
  27.  
  28.  
  29. bool areEqual(int array1[], int array2[])
  30. {
  31.     for(int i = 0; i < DIM; i ++)
  32.     {
  33.         if(array1[i] != array2[i])
  34.         {
  35.             return false;
  36.         }
  37.     }
  38.  
  39.  
  40.     return true;
  41. }
  42.  
  43.  
  44. int main()
  45. {
  46.     int array1[DIM] = {1,2,12,4,12};
  47.     int array2[DIM] = {13,4,12,2,1};
  48.  
  49.  
  50.     if(areEqual(sort(array1), sort(array2)))
  51.     {
  52.         printf("I due array sono uguali");
  53.     }
  54.     else
  55.     {
  56.         printf("I due array non sono uguali");
  57.     }
  58.  
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement