1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
using std::cout;
using std::endl;
using std::setprecision;
using std::string;
void printArray(string[], int);
void userInputArray(string array[], int size);
int userInputDriver(std::string[], int size);
int userInputCarColor(std::string[], int size);
int userInputTime(string array[], int size);
int main()
{
//double carnumber[3];
string driver_name[3];
string CarColor[3];
string Time[3];
//double position[3];
// string array
string car1[3];
string car2[3];
string car3[3];
string time1[3];
string time2[3];
string time3[3];
string color1[3];
string color2[3];
string color3[3];
userInputArray(car1, 3);
userInputArray(car2, 3);
userInputArray(car3, 3);
userInputArray(time1, 3);
userInputArray(time2, 3);
userInputArray(time3, 3);
userInputArray(color1, 3);
userInputArray(color2, 3);
userInputArray(color3, 3);
printArray(car1, 3);
printArray(car2, 3);
printArray(car3, 3);
}
void printArray(string array[], int size)
{
for (int i = 0; i < size; i++)
{
cout << array[i] << endl;
}
}
void userInputArray(string array[], int size)
{
cout << "Choose a carnumber ?" << endl;
cin >> array[0];
cout << "Choose a carcolor ?" << endl;
cin >> array[1];
cout << "Choose a laptime ?" << endl;
cin >> array[2];
}
int userInputDriver(std::string[], int size)
{
return 0;
}
int userInputCarColor(std::string[], int size)
{
return 0;
}
int userInputTime(string array[], int size)
{
return 0;
}
if (time1 < time2 && time1 < time3); //check if car1 came in first
{
if (time1 < time2) //if yes, check where car2 and car3 placed
{
cout << car1 << color1 << " came in first with a score of " << time1 << endl;
cout << car2 << color2 << " came in seconf with a score of " << time2 << endl;
cout << car3 << color3 << " came in third with a score of " << time3 << endl;
}
else
{
cout << car1 << color1 << " came in first with a score of " << time1 << endl;
cout << car3 << color3 << " came in second with a score of " << time3 << endl;
cout << car2 << color2 << " came in third with a score of " << time2 << endl;
}
}
if (time2 < time1 && time2 < time3) // check if car2 came first
{
if (time1 < time3) //if yes, check where car1 and car3 placed
{
cout << car2 << color2 << " came in first with a score of " << time2 << endl;
cout << car1 << color1 << " came in second with a score of " << time1 << endl;
cout << car3 << color3 << " came in third with a score of " << time3 << endl;
}
else car2
{
cout << car2 << color2 << " came in first with a score of " << time3 << endl;
cout << car1 << color1 << " came in second with a score of " << time1 << endl;
cout << car2 << color2 << " came in third with a score of " << time2 << endl;
return 0;
}
}
}
system("pause");
void myfunc()
{
cout << " Thanks for playing My Car Race" << endl;
}
|