Advertisement
mariacv

22

Nov 17th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int t, i, j;
  7. int flag1 = 1, flag2 = 0;
  8. char nomes[20][20];
  9. double limite;
  10. double tempos[20][3];
  11. double menor[20];
  12.  
  13. printf("digite a quantidade de corredores\n");
  14. scanf("%d", &t);
  15.  
  16. printf("digite o tempo limite\n");
  17. scanf("%lf", &limite);
  18.  
  19. for(i = 0; i < 20; i++)
  20. {
  21. menor[i] = limite;
  22. }
  23.  
  24. for(i = 0; i < t; i++)
  25. {
  26. printf("digite o nome do corredor %d\n", i + 1);
  27. scanf("%s", nomes[i]);
  28.  
  29. for(j = 0; j < 3; j++)
  30. {
  31. printf("digite o tempo %d do corredor %ds\n", j + 1, i + 1);
  32. scanf("%lf", &tempos[i][j]);
  33.  
  34. if(tempos[i][j] < menor[i])
  35. {
  36. menor[i] = tempos[i][j];
  37. }
  38. }
  39. }
  40.  
  41. for(i = 0; i < t; i++)
  42. {
  43. flag1 = 1;
  44.  
  45. for(j = 0; j < 3 && flag1 == 1; j++)
  46. {
  47. if(menor[i] > limite)
  48. flag1 = 0;
  49. }
  50. if(flag1 == 1)
  51. {
  52. flag2 = 1;
  53. printf("%s com o tempo de %lf\n", nomes[i], menor[i]);
  54. }
  55. }
  56. if(flag2 == 0)
  57. printf("todos os corredores sao perdedores");
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement