Advertisement
luluinstalock

Untitled

Feb 15th, 2016
1,676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void function(*tablicaIn, int n) {
  2.     int x = -1;
  3.     int p = -1;
  4.  
  5.     for (int i = 0;i < n;i++) {
  6.         int tmpx = tablicaIn[i];
  7.         int tmpp = 1;
  8.         for (int j = i + 1;j < n;j++) {
  9.             if (tmpx == tablicaIn[j])
  10.                 tmp++;
  11.         }
  12.         if (tmpp > p) {
  13.             p = tmpp;
  14.             x = tmpx;
  15.         }
  16.         else if (p == tmpp) {
  17.             if (tmpx > x) {
  18.                 x = tmpx;
  19.             }
  20.         }
  21.     }
  22.     int* tablicaOut = (int*)malloc(n*sizeof(int));
  23.     int k = 0;
  24.     for (int i = 0;i < n;i++) {
  25.         if (tablicaIn[i] < x) {
  26.             tablicaOut[k] = tablicaIn[i];
  27.                 k++;
  28.         }
  29.     }
  30.     for (int i = 0;i < n;i++) {
  31.         if (tablicaIn[i] >= x) {
  32.             tablicaOut[k] = tablicaIn[i];
  33.             k++;
  34.         }
  35.     }
  36.     return tablicaOut;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement