What's new

Help Closed

Status
Not open for further replies.

IkaMusume

Forum Guru
Elite
Joined
Jan 27, 2018
Posts
1,008
Reaction
15,235
Points
1,876
Age
25
priv
 
Last edited:
Bale ito po yung fix sa problem niyo po.

C++:
#include <iostream>
#include <string.h>

using namespace std;
main(){
  
    string team1, team2;
    int p1, p2;
  
    for (int j=1; j<=4; j++)
    {
    cout << "GAME " << j << "\n";
    cout << "Input Team 1 name: ";
    cin >> team1;
    cout << "Input Team 2 name: ";
    cin >> team2;
    for (int i=1; i<=3; i++)
        {
        cout << "Round " << i << ": " << endl;
        cout << "\tTeam " << team1 << " Points: ";
        cin >> p1;
      
        cout << "\tTeam " << team2 << " Points: ";
        cin >> p2;
        cout << "================================\n";
            if (p1 > p2)
                {
                    cout << "Winner: Team " << team1 << endl;
                }
            else if (p1 < p2)
                {
                    cout << "Winner: Team " << team2 << endl;
                }
            else
                {
                    cout << "No winner\n";
                }
        }
    }
}
 
Bale ito po yung fix sa problem niyo po.

C++:
#include <iostream>
#include <string.h>

using namespace std;
main(){
 
    string team1, team2;
    int p1, p2;
 
    for (int j=1; j<=4; j++)
    {
    cout << "GAME " << j << "\n";
    cout << "Input Team 1 name: ";
    cin >> team1;
    cout << "Input Team 2 name: ";
    cin >> team2;
    for (int i=1; i<=3; i++)
        {
        cout << "Round " << i << ": " << endl;
        cout << "\tTeam " << team1 << " Points: ";
        cin >> p1;
    
        cout << "\tTeam " << team2 << " Points: ";
        cin >> p2;
        cout << "================================\n";
            if (p1 > p2)
                {
                    cout << "Winner: Team " << team1 << endl;
                }
            else if (p1 < p2)
                {
                    cout << "Winner: Team " << team2 << endl;
                }
            else
                {
                    cout << "No winner\n";
                }
        }
    }
}
natry ko na rin po ang std::cin. prefer ko po sana yung may space ang mga teams if ever, instructed din ng instructor

btw thank you very much po
 
patry



#include <iostream>
#include <string.h>
using namespace std;
int main() {
string team1, team2;
int p1, p2;

for (int j=1; j<=4; j++)
{
cout << "GAME " << j << endl;
cout << "Input Team 1 name: ";
cin>>team1;
cout << "Input Team 2 name: ";
cin>>team2;
for (int i=1; i<=3; i++)
{
cout << "Round " << i << ": " << endl;
cout << "\tTeam " << team1 << " Points: ";
cin >> p1;
cout << "\tTeam " << team2 << " Points: ";
cin >> p2;
cout << "================================\n";
if (p1 > p2)
{
cout << "Winner: Team " << team1 << endl;
}
else if (p1 < p2)
{
cout << "Winner: Team " << team2 << endl;
}
else
{
cout << "No winner\n";
}
cout<<endl;
}
}
return 0;
}
 
Status
Not open for further replies.

Similar threads

Back
Top