Win counter and enlist the winners every game

Hello, I tried to make game where you can determine the winner by inputting their scores
i'm just confuse how to count the wins of one team
also im confuse how to enlist the winners in 3 games as indicated inside the for loop, those slashes are my trial and error but no luck.

here's my code:
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
#include <iostream>
#include <string.h>

using namespace std;
main(){

    int p1, p2, a=4;
    int wincount=0;
    string team1, team2;
    for (int j=0; j<a; j++)
    {

    cout << "GAME " << j+1 << "\n";
    cout << "Input Team 1 name: ";
    cin >> team1;
    cout << "Input Team 2 name: ";
    cin >> team2;
    for (int v=1; v<=3; v++)
        {
        cout << "Round " << v << ": " << endl;
        cout << "\tTeam " << team1 << " Points: ";
        cin >> p1;

        cout << "\tTeam " << team2 << " Points: ";
        cin >> p2;
        cout << "================================\n";

            if (p1 > p2)
                {
                    cout << "Winner: Team " << team1 << endl;
                    wincount += 1;
                }
            else if (p1 < p2)
                {
                    cout << "Winner: Team " << team2 << endl;
                    wincount += 1;
                }
            else
                {
                    cout << "No winner\n";
                }
        }
        cout << "Team " << team1 << ": " << wincount << "wins(s)" << endl;
        cout << "Team " << team2 << ": " << wincount << "wins(s)" << endl;
        cout << "Game " << j+1 << "Winner: ";
    }
    //cout << "Summary of winners: ";
    //for (int i=1; i<a; ++i)
    //{
    //  for(int v=i+1;v<a:v++)
    //  {
    //      
    //  }
    //}
}

expected output for the first part

GAME 1
Input Team 1 name: 22
Input Team 2 name: Lols
Round 1:
 Team 22 Points: 20
 Team Lols Points: 20
 ______________________________
 NO WINNER!
Round 2:
 Team 22 Points: 19
 Team Lols Points: 20
 ______________________________
 Winner: Team Lols
Round 3:
 Team 22 Points: 25
 Team Lols Points: 30
 ______________________________
 Winner: Team Lols
Team 22: 0 WIN(S)
Team Lols: 2 WIN(S)
GAME 2 WINNER: Team Lols

Expected output for winner last at the last part
SUMMARY OF WINNERS:
 Game 1: Team1
 Game 2: Team34
 Game 3: Team Lols
 Game 4: Team 45

any help is appreciated
PS: I don't use, void, public, class, struggle,bool or anything advance c++ topics
Last edited on
Consider:

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
#include <iostream>
#include <string>

int main() {
	constexpr size_t NoGames {4};
	constexpr size_t NoRnd {3};
	std::string winners[NoGames];

	for (size_t j {}; j < NoGames; ++j) {
		std::string team1, team2;
		int p1 {}, p2 {};
		size_t t1cnt {}, t2cnt {};

		std::cout << "\nGAME " << j + 1 << '\n';
		std::cout << "Input Team 1 name: ";
		std::cin >> team1;
		std::cout << "Input Team 2 name: ";
		std::cin >> team2;

		for (size_t v {1}; v <= NoRnd; ++v) {
			std::cout << "Round " << v << ":\n";
			std::cout << "\tTeam " << team1 << " Points: ";
			std::cin >> p1;

			std::cout << "\tTeam " << team2 << " Points: ";
			std::cin >> p2;

			std::cout << "================================\n";

			if (p1 > p2) {
				std::cout << "Winner: Team " << team1 << '\n';
				++t1cnt;
			} else if (p1 < p2) {
				std::cout << "Winner: Team " << team2 << '\n';
				++t2cnt;
			} else
				std::cout << "No winner\n";
		}

		std::cout << "Team " << team1 << ": " << t1cnt << " wins(s)\n";
		std::cout << "Team " << team2 << ": " << t2cnt << " wins(s)\n";

		std::cout << "\nGame " << j + 1;
		if (t1cnt > t2cnt) {
			std::cout << " Winner Team " << team1 << '\n';
			winners[j] = team1;
		} else if (t2cnt > t1cnt) {
			std::cout << " Winner Team " << team2 << '\n';
			winners[j] = team2;
		} else {
			std::cout << " Draw!\n";
			winners[j] = "Draw";
		}
	}

	std::cout << "\nSummary of winners\n";

	for (size_t i {}; i < NoGames; ++i)
		std::cout << "Game " << i + 1 << ": " << winners[i] << '\n';
}

Oh my god! thank you very much may god bless you
Topic archived. No new replies allowed.