Advertisement
rdsedmundo

Aeroporto.c

Jan 9th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int i, j;
  5.  
  6.     for(i = 0;; i++) {
  7.         int A, V;
  8.         scanf("%d %d", &A, &V);
  9.  
  10.         if(!A && !V)
  11.             break;
  12.  
  13.         printf("Teste %d\n", i + 1);
  14.  
  15.         int Trafego[A];
  16.  
  17.         for(j = 0; j < A; j++)
  18.             Trafego[j] = 0;
  19.  
  20.         for(j = 0; j < V; j++) {
  21.             int from, dest;
  22.             scanf("%d %d", &from, &dest);
  23.  
  24.             Trafego[from - 1]++;
  25.             Trafego[dest - 1]++;
  26.         }
  27.  
  28.         int Maior = 0;
  29.  
  30.         for(j = 0; j < A; j++) {
  31.             if(Trafego[j] > Trafego[Maior])
  32.                 Maior = j;
  33.         }
  34.  
  35.         printf("%d", Maior + 1);
  36.  
  37.         for(j = 0; j < A; j++) {
  38.             if(j != Maior && Trafego[j] == Trafego[Maior])
  39.                 printf(" %d", j + 1);
  40.         }
  41.  
  42.         printf("\n");
  43.     }
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement