Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void function(*tablicaIn, int n) {
- int x = -1;
- int p = -1;
- for (int i = 0;i < n;i++) {
- int tmpx = tablicaIn[i];
- int tmpp = 1;
- for (int j = i + 1;j < n;j++) {
- if (tmpx == tablicaIn[j])
- tmp++;
- }
- if (tmpp > p) {
- p = tmpp;
- x = tmpx;
- }
- else if (p == tmpp) {
- if (tmpx > x) {
- x = tmpx;
- }
- }
- }
- int* tablicaOut = (int*)malloc(n*sizeof(int));
- int k = 0;
- for (int i = 0;i < n;i++) {
- if (tablicaIn[i] < x) {
- tablicaOut[k] = tablicaIn[i];
- k++;
- }
- }
- for (int i = 0;i < n;i++) {
- if (tablicaIn[i] >= x) {
- tablicaOut[k] = tablicaIn[i];
- k++;
- }
- }
- return tablicaOut;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement