I want to print the highest scored player..
How can I modify this program for get that output.?
the Player numbers are 100,101,102,103 .
Here im getting Maximum sum of each player.But it also gives the correct maximum sum if the maximun sum come from last column (last set of marks)..
now Im getting output like this
Round 1
Enter score of Player 100:2
Enter score of Player 101:2
Enter score of Player 102:2
Enter score of Player 103:2
Round 2
Enter score of Player 100:3
Enter score of Player 101:3
Enter score of Player 102:3
Enter score of Player 103:3
Round 3
Enter score of Player 100:4
Enter score of Player 101:4
Enter score of Player 102:4
Enter score of Player 103:4
Winner is 16
Can anyone help me to fix these problems ?
thanks..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include<iostream>
using namespace std;
void inputData(int data[][3],int rowSize,int colSize);
int FindWinner(int data[][3],int rowSize,int colSize);
int main()
{
int tbl [4][3];
inputData(tbl,3,4);
FindWinner(tbl,3,4);
return 0;
}
void inputData(int data[][3],int rowSize,int colSize)
{
for(int a=0;a<rowSize;a++)
{
cout<<"Round "<<a+1<<endl;
for(int b=0;b<colSize;b++)
{
cout<<" Enter score of Player 10"<<b<<":" ;
cin>>data[a][b];
}
}
}
int FindWinner (int data[][3],int rowSize,int colSize)
{
int maxsum;
int sum ;
for(int a=0;a<rowSize;a++)
{sum =0;
for(int b=0;b<colSize;b++)
{
sum=sum + data[a][b];
}
if(sum>maxsum)
maxsum =sum;
}
cout<<"Winner is "<<maxsum<<endl;
}
|