Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main(){
  5.  
  6.     int nvoltas;
  7.     int volta;
  8.     int i = 1;
  9.     int melhor = 10000;
  10.     int pior = -10000;
  11.     int nmelhor;
  12.     int npior;
  13.     int total = 0;
  14.     printf("Digite o numero de voltas \n");
  15.     scanf("%d", &nvoltas);
  16.  
  17.     for(i = 1; i <= nvoltas; i++){
  18.         printf("Digite o tempo da volta %d: ", i);
  19.         scanf("%d", &volta);
  20.        
  21.         if(volta > 0){
  22.             total += volta;
  23.  
  24.             if(volta < melhor){
  25.                 melhor = volta;
  26.                 nmelhor = i;
  27.             }
  28.  
  29.             if(volta > pior){
  30.                 pior = volta;
  31.                 npior = i;
  32.             }
  33.        
  34.         }
  35.         else{
  36.             if(volta == -1){
  37.             total += 10;
  38.             }
  39.             else if(volta == -2){
  40.                 total += 25;
  41.             }
  42.             else if(volta == -3){
  43.                 total += 40;
  44.             }
  45.         }
  46.        
  47.        
  48.         total += volta;
  49.  
  50.        
  51.  
  52.  
  53.     }
  54.  
  55.     printf("Melhor volta: %d - %d seg\n", nmelhor, melhor);
  56.     printf("Pior volta: %d - %d seg\n", npior, pior);
  57.     printf("Tempo Total: %d", total);
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement