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

here's my code:

#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++)
    //  {
    //      
    //  }
    //}
}

i'm also 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.

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

Uhm, 'struggle'? I have no idea what that refers to in this context. OTOH, void just means a function doesn't return a value, or conversely, that a pointer doesn't have a type.

Mind you, I don't think this code would even compile under most compilers today, or at least would give few warnings about it. The main() function must - I repeat, must - be declared as int in C++, and return some sort of value, no ifs, ands, or buts. Furthermore, <string.h> was renamed to just <string> in 1998, and most modern compilers won't allow that header - or if they do, they assume you want the C string library (renamed to <cstring> in modern C++, but still sometimes used in older code) rather than the C++ string class library. If you don't mind me asking, what compiler are you using?

Getting to the problem at hand, I would suggest that you have separate wincount variables for each of the teams; as it is, you are just counting how many games were played (except in the cases of ties). The simplest way to do this would be to declare two variables, wincount1 and wincount2, and use those to count the wins for the individual teams, rather than the aggregate of both.

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

        if (p1 > p2)
            {
                cout << "Winner: Team " << team1 << endl;
                wincount1 += 1;
            }
        else if (p1 < p2)
            {
                cout << "Winner: Team " << team2 << endl;
                wincount2 += 1;
            }
        else
            {
                cout << "No winner\n";
            }
    }

A somewhat more advanced approach would be to use an array, wincount[], of two int values, and do the same for your team names:

int p[2], a=4;
int wincount[2];
string teams[2];

cout << "GAME " << j+1 << "\n";
cout << "Input Team 1 name: ";
cin >> team[0];
cout << "Input Team 2 name: ";
cin >> team[1];
for (int v=1; v<=3; v++)
    {
    cout << "Round " << v << ": " << endl;
    cout << "\tTeam " << team[0] << " Points: ";
    cin >> p[0];

    cout << "\tTeam " << team[1] << " Points: ";
    cin >> p[1];
    cout << "================================\n";

        if (p[0] > p[1])
            {
                cout << "Winner: Team " << team[0] << endl;
                wincount[0] += 1;
            }
        else if (p[0] < p[1])
            {
                cout << "Winner: Team " << team[1] << endl;
                wincount[1] += 1;
            }
        else
            {
                cout << "No winner\n";
            }
    }

Better still, if perhaps a bit beyond your experience right now, would be to declare a struct type with a name, points from the current match, and the win count as part of it:

#include <iostream>
#include <string>

using namespace std;

struct Team {
    string name;
    int points = 0;
    int wins = 0;
};

int main(){

int a=4;
Team team[2];
for (int j=0; j<a; j++)
{

cout << "GAME " << j+1 << "\n";
cout << "Input Team 1 name: ";
cin >> team[0].name;
cout << "Input Team 2 name: ";
cin >> team[1].name;
for (int v=1; v<=3; v++)
    {
    cout << "Round " << v << ": " << endl;
    cout << "\tTeam " << team[0] << " Points: ";
    cin >> team[0].points;

    cout << "\tTeam " << team[1].name << " Points: ";
    cin >> team[1].points;
    cout << "================================\n";

        if (team[0].points > team[1].points)
            {
                cout << "Winner: Team " << team[0].name << endl;
                team[0].wins++;
            }
        else if (team[0].points < team[1].points)
            {
                cout << "Winner: Team " << team[1] << endl;
                team[1].wins++;
            }
        else
            {
                cout << "No winner\n";
            }
    }
    cout << "Team " << team[0].name << ": " << team[0].wins << "wins(s)" << endl;
    cout << "Team " << team[1].name << ": " << team[1].wins << "wins(s)" << endl;
    cout << "Game " << j+1 << "Winner: ";

    if (team[0].wins > team[1].wins)
        {
        cout << team[0].name << " wins the tournament." << endl;
        }
    else if (team[0].wins < team[1].wins)
        {
        cout << team[1].name << " wins the tournament." << endl;
        }
    else
        {
        cout << Tied overall." << endl;
        }

    return 0;  // success
}
commented: +1 for the win. +16
commented: It worked! I've derived some codes and it finally run. Thank you very much +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.