Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- struct atleta
- {
- char nombre[20];
- float marca;
- };
- float mejormarca(float, float, float);
- int main(int argc, char** argv)
- {
- float y,z,t,a;
- int i = 0;
- char x[10];
- atleta persona[10], aux;
- bool k = true;
- do{
- cout<< "Ingrese nombre de atleta" << endl;
- cin >> persona[i].nombre;
- cout<< "Ingrese las tres marcas del atleta" << endl;
- cin >> y;
- cin>> z;
- cin >> t;
- a=mejormarca(y,z,t);
- persona[i].marca = a;
- i++;
- cout << "Desea agregar mas personas -> 1/0 "; cin >> k;
- }
- while (k == true);
- for (int j = 0; j<i ; j++){
- for (int c=0; c<i; c++){
- if (persona[c].marca < persona[c+1].marca){
- aux = persona [c];
- persona[c] = persona [c+1];
- persona[c+1] = aux;
- }
- }
- }
- for (int j = 0; j<i ; j++){
- cout << " NOMBRE -> " << persona[j].nombre << " SALTO -> " << persona[j].marca << endl;
- }
- return 0;
- }
- float mejormarca(float x, float y, float z)
- {
- if(x>y && x>z)
- {
- return x;
- }
- else if (y>x && y>z)
- {
- return y;
- }
- else
- return z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement