IvoSilva

[PROG1] Mini-Teste Exemplo #1 | Exercício 2.1

Nov 19th, 2011
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.   int i , n , minutes , time , seconds , minpos = 0 , min = 999 , soma = 0 ;
  5.   scanf ("%d" , &n) ;
  6.   for (i = 0 ; i < n ; i++)
  7.   {
  8.     scanf ("%d %d" , &minutes , &seconds) ;
  9.     time = minutes * 60 + seconds ;
  10.     if (time < min)
  11.     {
  12.       min = time ;
  13.       minpos = i + 1 ;
  14.     }
  15.     soma += time ;
  16.   }
  17.   printf ("O melhor tempo de todas as voltas foi %d minutos e %d segundos.\n" , min / 60 , min % 60) ;
  18.   printf ("O melhor tempo ocorreu na volta número %d.\n" , minpos) ;
  19.   printf ("O tempo médio de todas as voltas foi %d minutos e %d segundos.\n" , soma / 60 / n , soma / n % 60) ;
  20.   return 0 ;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment