Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- ofstream dout;
- fstream din;
- //Declare Arrays
- int GAMES = 500;
- int i = 0;
- int score_1[GAMES];
- string team_1[GAMES];
- int score_2[GAMES];
- string team_2[GAMES];
- int s = 0;
- string desired;
- char ch;
- //Open the File
- din.open("games.txt");
- //Read the file and fill arrays
- while (din >> score_1[i] >> team_1[i] >> score_2[i] >> team_2[i])
- {
- //din >> score_1[i] >> team_1[i] >> score_2[i] >> team_2[i];
- //cout << score_1[i] << " " << team_1[i] << " " << score_2[i] << " " << team_2[i];
- i++;
- }
- //Close input file
- din.close();
- cout << "Which team do you want to see scores for?" << endl;
- cin >> desired;
- //Search the team arrays for the desired team
- for(i = 0; i <= GAMES; i++)
- {
- if (((team_1[i] == desired) || ((team_2[i] == desired)) && (score_1[i] < score_2[i])))
- {using namespace std;
- cout << setw(4) << "0 " << score_1[i]<< setw(20) << team_1[i] << setw(4) << " 1 " << score_2[i] << setw(20) << team_2[i] << endl;
- }
- else if (((team_1[i] == desired) || (team_2[i] == desired)) && (score_1[i] > score_2[i]))
- {using namespace std;
- cout << setw(4) << "0 " << score_1[i]<< setw(20) << team_1[i] << setw(4) << " 1 " << score_2[i] << setw(20) << team_2[i] << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement