Program takes in 5 teams no matter what right now but I want the user to state how many teams there are first, then go off of that number instead of the default 5.
I like jumping out of airplanes*/
#include <iostream>
using namespace std;
void initializeArrays(string names[], int wins[], int size);
void sortData(string names[], int wins[], int size);
void displayData(string names[], int wins[], int size);
int main()
{
const int NUM_TYPES = 5;
int numTeams;
int* ptr = NULL;
cout << "How many teams will you enter?: ";
cin >> numTeams;
string names[NUM_TYPES] = {};
int wins[NUM_TYPES] = {};
initializeArrays(names, wins, 5);
sortData(names, wins, 5);
displayData(names, wins, 5);
return 0;
}
void initializeArrays(string names[], int wins[], int size) {
int rotations[5] = { 1, 2, 3, 4, 5 };
for (int i = 0; i < 5; i++) {
cout << "Enter team #" << rotations[i] << ": ";
cin >> names[i];
cout << "Enter the wins for team #" << rotations[i] << ": ";
cin >> wins[i];
} return;
}
void sortData(string names[], int wins[], int size) {
for (int j = 0; j < 5; j++) {
for (int i = 0; i < 5 - 1; i++) {
if (wins[i] < wins[i + 1]) {
string temp;
temp = names[i];
names[i] = names[i + 1];
names[i + 1] = temp;
int x = wins[i];
wins[i] = wins[i + 1];
wins[i + 1] = x;
}
}
}
return;
}
void displayData(string names[], int wins[], int size) {
int rotations[5] = { 1, 2, 3, 4, 5 };
cout << "League Standings:" << endl;
for (int i = 0; i < 5; i++) {
cout << names[i] << ": " << wins[i] << endl;
}
return;
}