# [C++] Point Calculation

By: Jeclipse on Aug 3rd, 2012  |  syntax: C++  |  size: 0.92 KB  |  hits: 18  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5.         int n, max=0;
6.         int wins[50]={0}; //Initiate 3 arrays to fill with wins or losses
7.         int ties[50]={0}; //then calculate the max
8.         int points[50]={0};
9.         cout<<"Insert test cases: "; //Input number of cases
10.         cin>>n;
11.         for(int i=0; i<n; i++)
12.         {
13.                 do{
14.                 cout<<"How many wins has team "<<i+1<<" obtained: ";
15.                 cin>>wins[i];//fill the array with team wins
16.                 }while(wins[i]<0||wins[i]>100); }
17.         for(int i=0; i<n; i++)
18.         {
19.                 do{
20.                 cout<<"How many ties has team "<<i+1<<" obtained: ";
21.                 cin>>ties[i];//fill the array with team ties
22.                 }while(ties[i]<0||ties[i]>100); }
23.         for(int i=0; i<n; i++)
24.         {
25.                 points[i]=(wins[i]*3)+ties[i];//calculate total points for every ith case
26.                 if(points[i]>max)
27.                         max=points[i];//scan array for biggest value and store it in max
28.
29.
30.         }
31.         cout<<"The maximum number of points a team has is: "<<max<<endl;//output
32.         system("pause");
33.         return 0;
34. }