
[C++] Point Calculation
By:
Jeclipse on
Aug 3rd, 2012 | syntax:
C++ | size: 0.92 KB | hits: 18 | expires: Never
#include <iostream>
using namespace std;
int main()
{
int n, max=0;
int wins[50]={0}; //Initiate 3 arrays to fill with wins or losses
int ties[50]={0}; //then calculate the max
int points[50]={0};
cout<<"Insert test cases: "; //Input number of cases
cin>>n;
for(int i=0; i<n; i++)
{
do{
cout<<"How many wins has team "<<i+1<<" obtained: ";
cin>>wins[i];//fill the array with team wins
}while(wins[i]<0||wins[i]>100); }
for(int i=0; i<n; i++)
{
do{
cout<<"How many ties has team "<<i+1<<" obtained: ";
cin>>ties[i];//fill the array with team ties
}while(ties[i]<0||ties[i]>100); }
for(int i=0; i<n; i++)
{
points[i]=(wins[i]*3)+ties[i];//calculate total points for every ith case
if(points[i]>max)
max=points[i];//scan array for biggest value and store it in max
}
cout<<"The maximum number of points a team has is: "<<max<<endl;//output
system("pause");
return 0;
}