Advertisement
Guest User

Untitled

a guest
May 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. struct atleta
  8. {
  9. char nombre[20];
  10. float marca;
  11. };
  12.  
  13.  
  14.  
  15.  
  16.  
  17. float mejormarca(float, float, float);
  18.  
  19. int main(int argc, char** argv)
  20. {
  21. float y,z,t,a;
  22. int i = 0;
  23. char x[10];
  24. atleta persona[10], aux;
  25.  
  26.  
  27. bool k = true;
  28.  
  29. do{
  30. cout<< "Ingrese nombre de atleta" << endl;
  31. cin >> persona[i].nombre;
  32. cout<< "Ingrese las tres marcas del atleta" << endl;
  33. cin >> y;
  34. cin>> z;
  35. cin >> t;
  36. a=mejormarca(y,z,t);
  37. persona[i].marca = a;
  38. i++;
  39. cout << "Desea agregar mas personas -> 1/0 "; cin >> k;
  40. }
  41. while (k == true);
  42.  
  43.  
  44. for (int j = 0; j<i ; j++){
  45.  
  46. for (int c=0; c<i; c++){
  47.  
  48. if (persona[c].marca < persona[c+1].marca){
  49.  
  50. aux = persona [c];
  51. persona[c] = persona [c+1];
  52. persona[c+1] = aux;
  53.  
  54. }
  55.  
  56. }
  57. }
  58.  
  59. for (int j = 0; j<i ; j++){
  60.  
  61.  
  62. cout << " NOMBRE -> " << persona[j].nombre << " SALTO -> " << persona[j].marca << endl;
  63.  
  64.  
  65. }
  66.  
  67.  
  68. return 0;
  69. }
  70.  
  71.  
  72.  
  73. float mejormarca(float x, float y, float z)
  74. {
  75. if(x>y && x>z)
  76. {
  77. return x;
  78. }
  79. else if (y>x && y>z)
  80. {
  81. return y;
  82. }
  83. else
  84. return z;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement