Skip to content

Instantly share code, notes, and snippets.

@lamhoangtung
Created July 24, 2019 15:33
Show Gist options
  • Save lamhoangtung/7dab2b990c3928200c43e0904c376a60 to your computer and use it in GitHub Desktop.
Save lamhoangtung/7dab2b990c3928200c43e0904c376a60 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
for (int i = 0; i < 2; i++)
{
string di;
getline(cin, di);
int j = 0;
while (isalpha(di[j]))
{
j++;
}
string team1 = di.substr(0, j);
j++;
int k = j;
int dem = 0;
while (di[j] != ' ')
{
dem++;
j++;
}
int score1 = stoi(di.substr(k, dem));
j += 3;
k = j;
dem = 0;
while (di[j] != ' ')
{
dem++;
j++;
}
int score2 = stoi(di.substr(k, dem));
string team2 = di.substr(j + 1);
string ve;
getline(cin, ve);
j = 0;
while (isalpha(ve[j]))
{
j++;
}
j++;
k = j;
dem = 0;
while (ve[j] != ' ')
{
dem++;
j++;
}
int score3 = stoi(ve.substr(k, dem));
j += 3;
k = j;
dem = 0;
while (ve[j] != ' ')
{
dem++;
j++;
}
int score4 = stoi(ve.substr(k, dem));
if (score1 + score4 > score2 + score3)
{
cout << team1;
}
if (score1 + score4 < score2 + score3)
{
cout << team2;
}
if (score1 + score4 == score2 + score3)
{
if (score2 < score4)
{
cout << team1;
}
else
{
cout << team2;
}
}
if (i == 0)
cout << " - ";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment