Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. int firstThreePlaces(struct athletesInformation arrayOfAthletes[], int sizeOfArray)
  2. {
  3.  
  4.     int FirstPlace = 0 ;
  5.     int SecondPlace = 0;
  6.     int ThirdPlace = 0 ;
  7.    
  8.  
  9.     for (int i = 0; i < sizeOfArray; i++)
  10.     {
  11.         if ((arrayOfAthletes[i].athelteRaceTime < arrayOfAthletes[FirstPlace].athelteRaceTime) && (arrayOfAthletes[i].athelteRaceTime != NULL))
  12.         {
  13.             SecondPlace = FirstPlace;
  14.             FirstPlace = i;
  15.         }
  16.     }
  17.     for (int i = 0; i < sizeOfArray; i++)
  18.     {
  19.         if (arrayOfAthletes[i].athelteRaceTime < arrayOfAthletes[SecondPlace].athelteRaceTime && arrayOfAthletes[i].athelteRaceTime  > arrayOfAthletes[FirstPlace].athelteRaceTime && arrayOfAthletes[i].athelteRaceTime != NULL)
  20.         {
  21.             SecondPlace = i;
  22.         }
  23.     }
  24.     for (int i = 0; i < sizeOfArray; i++)
  25.     {
  26.         if (arrayOfAthletes[i].athelteRaceTime < arrayOfAthletes[ThirdPlace].athelteRaceTime && arrayOfAthletes[i].athelteRaceTime > arrayOfAthletes[SecondPlace].athelteRaceTime && arrayOfAthletes[i].athelteRaceTime != NULL)
  27.         {
  28.             ThirdPlace = i;
  29.         }
  30.     }
  31.  
  32.    
  33.     cout << arrayOfAthletes[FirstPlace].athleteFirstName << " " << arrayOfAthletes[FirstPlace].athelteLastName << " won the first place with the time of " << arrayOfAthletes[FirstPlace].athelteRaceTime << endl
  34.             << arrayOfAthletes[SecondPlace].athleteFirstName << " " << arrayOfAthletes[SecondPlace].athelteLastName << " won the second place with the time of "<< arrayOfAthletes[SecondPlace].athelteRaceTime << endl
  35.             << arrayOfAthletes[ThirdPlace].athleteFirstName << " " << arrayOfAthletes[ThirdPlace].athelteLastName << " won the third place with the time of " << arrayOfAthletes[ThirdPlace].athelteRaceTime << endl;
  36.  
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement