这是我第一次尝试 for 循环,我遇到了一些问题。我正在尝试编写一个程序,询问两支球队每节得分多少,然后显示总分和获胜球队。
#include <iostream>
using namespace std;
int main( )
{
int scoreA = 0;
int scoreB = 0;
cout << "This program calculates the average score of 10 tests." << endl;
for (int counter = 0; counter < 4; counter = counter + 1)
{
cout << "Enter Team A's quarterly points: ";
cin >> scoreA;
cout << "Enter Team B's quarterly points: ";
cin >> scoreB;
scoreA = scoreA + scoreA;
scoreB = scoreB + scoreB;
}
cout << "Team A's Score: " << scoreA << endl;
cout << "Team B's Score: " << scoreB << endl;
if (scoreA > scoreB)
{
cout << "Team A wins";
}
else
{
cout << "Team B wins";
}
system("pause");
return 0;
}