Advertisement
Guest User

Untitled

a guest
Nov 17th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11. ofstream dout;
  12. fstream din;
  13.  
  14. //Declare Arrays
  15.  
  16. int GAMES = 500;
  17. int i = 0;
  18.  
  19. int score_1[GAMES];
  20. string team_1[GAMES];
  21. int score_2[GAMES];
  22. string team_2[GAMES];
  23. int s = 0;
  24. string desired;
  25. char ch;
  26. //Open the File
  27. din.open("games.txt");
  28.  
  29.  
  30. //Read the file and fill arrays
  31. while (din >> score_1[i] >> team_1[i] >> score_2[i] >> team_2[i])
  32. {
  33.  
  34.  
  35. //din >> score_1[i] >> team_1[i] >> score_2[i] >> team_2[i];
  36.  
  37. //cout << score_1[i] << " " << team_1[i] << " " << score_2[i] << " " << team_2[i];
  38.  
  39. i++;
  40.  
  41. }
  42.  
  43. //Close input file
  44. din.close();
  45.  
  46. cout << "Which team do you want to see scores for?" << endl;
  47. cin >> desired;
  48.  
  49.  
  50. //Search the team arrays for the desired team
  51.  
  52. for(i = 0; i <= GAMES; i++)
  53. {
  54.  
  55.  
  56. if (((team_1[i] == desired) || ((team_2[i] == desired)) && (score_1[i] < score_2[i])))
  57. {using namespace std;
  58. cout << setw(4) << "0 " << score_1[i]<< setw(20) << team_1[i] << setw(4) << " 1 " << score_2[i] << setw(20) << team_2[i] << endl;
  59. }
  60.  
  61. else if (((team_1[i] == desired) || (team_2[i] == desired)) && (score_1[i] > score_2[i]))
  62. {using namespace std;
  63. cout << setw(4) << "0 " << score_1[i]<< setw(20) << team_1[i] << setw(4) << " 1 " << score_2[i] << setw(20) << team_2[i] << endl;
  64. }
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement