Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #define _CRT_SECURE_NO_WARNINGS
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <stdbool.h>
  8. #include <math.h>
  9.  
  10. #include "train.h"
  11. #define LEN 10
  12.  
  13. struct Train train_max(Train * a[]) {
  14.     //int q = sizeof(a) / sizeof(Train);
  15.     int b[LEN], max = -1;
  16.     for (int i = 0; i < LEN; i++) {
  17.         b[i] = 0;
  18.     }
  19.     for (int i = 0; i < LEN; i++) {
  20.         if (a[i]->num != -1) {
  21.             int p = a[i]->num;
  22.             for (int j = 0; j < LEN; j++) {
  23.                 if (a[j]->num == p) {
  24.                     b[i]++;
  25.                     a[j]->num = -1;
  26.                 }
  27.             }
  28.             if (b[i] > max) {
  29.                 max = b[i];
  30.             }
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement