Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- enum nem {fiu, lany};
- typedef enum nem nem;
- struct tanulo
- {
- nem neme;
- int magassag;
- };
- typedef struct tanulo tanulo;
- int par(tanulo t1, tanulo t2)
- {
- if ((t1.neme != t2.neme) && ((abs(t1.magassag - t2.magassag)) < 10))
- {
- return 1;
- }
- return 0;
- }
- int hanypar(tanulo *p, int size, tanulo t)
- {
- int parok = 0;
- for (int i = 0; i < size; i++)
- {
- if (par(p[i], t) == 1)
- {
- parok++;
- }
- }
- return parok;
- }
- osztalymax(tanulo *p, int size, int *max, int *parok)
- {
- int maxindex = 0;
- int maxertek = p[maxindex].magassag;
- for (int i = 1; i < size; i++)
- {
- if (p[i].magassag > maxertek)
- {
- maxertek = p[i].magassag;
- maxindex = i;
- }
- }
- *max = maxindex;
- *parok = hanypar(p, size, p[maxindex]);
- }
- int main()
- {
- int legmagasabb;
- int parok;
- tanulo osztaly[10] =
- {
- {fiu, 170},
- {lany, 171},
- {fiu, 163},
- {lany, 172},
- {fiu, 180},
- {lany, 168},
- {fiu, 179},
- {lany, 158},
- {fiu, 167},
- {lany, 172}
- };
- osztalymax(osztaly, 6, &legmagasabb, &parok);
- printf("Index %d, parok szama %d\n", legmagasabb, parok);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement