Source code
#include <stdio.h>
struct playearst1
{
char name[100];
char country[100];
int run[3];
int wicket[3];
int points[3];
};
int point1(struct playearst1 t1[3], int i)
{
int j;
for(j=0; j<3; j++)
{
if(t1[i].run[j]<25)
{
t1[i].points[j]=(t1[i].wicket[j]*12);
}
else if(t1[i].run[j]>=25 && t1[i].run[j]<50)
{
t1[i].points[j]=5+(t1[i].wicket[j]*12);
}
else if(t1[i].run[j]>=50 && t1[i].run[j]<75)
{
t1[i].points[j]=5+10+(t1[i].wicket[j]*12);
}
else if(t1[i].run[j]>=75 && t1[i].run[j]<100)
{
t1[i].points[j]=5+10+15+(t1[i].wicket[j]*12);
}
else if(t1[i].run[j]>=100)
{
t1[i].points[j]=5+10+15+20+(t1[i].wicket[j]*12);
}
}
}
int point2(struct playearst1 t2[3], int i)
{
int j;
for(j=0; j<3; j++)
{
if(t2[i].run[j]<25)
{
t2[i].points[j]=(t2[i].wicket[j]*12);
}
else if(t2[i].run[j]>=25 && t2[i].run[j]<50)
{
t2[i].points[j]=5+(t2[i].wicket[j]*12);
}
else if(t2[i].run[j]>=50 && t2[i].run[j]<75)
{
t2[i].points[j]=5+10+(t2[i].wicket[j]*12);
}
else if(t2[i].run[j]>=75 && t2[i].run[j]<100)
{
t2[i].points[j]=5+10+15+(t2[i].wicket[j]*12);
}
else if(t2[i].run[j]>=100)
{
t2[i].points[j]=5+10+15+20+(t2[i].wicket[j]*12);
}
}
}
int MOM(struct playearst1 t1[3],struct playearst1 t2[3])
{
int i,j,max=0;
int array[3];
for(j=0; j<1; j++)
{
for(i=0; i<3; i++)
{
max=0;
if(t1[j].points[i]>max)
{
max=t1[j].points[i];
}
if(t2[j].points[i]>max)
{
max=t2[j].points[i];
}
array[i]=max;
}
}
for(j=0; j<1; j++)
{
for(i=0; i<3; i++)
{
printf("
The Match %d MOM is:
",i+1);
if(array[i]==t1[j].points[i])
{
printf("%s
",t1[j].name);
}
else if(array[i]==t2[j].points[i])
{
printf("%s
",t2[j].name);
}
}
}
return 0;
}
int MOS(struct playearst1 t1[3],struct playearst1 t2[3])
{
int i,j,max=0,sum=0;
int array1[11],array2[11];
for(i=0; i<1; i++) ///1st team each player total points count
{
for(j=0; j<3; j++)
{
sum+=t1[i].points[j];
}
array1[i]=sum;
sum=0;
}
for(i=0; i<1; i++) ///2nd team each player total points count
{
for(j=0; j<3; j++)
{
sum+=t2[i].points[j];
}
array2[i]=sum;
sum=0;
}
for(i=0;i<1;i++)
{
if(array1[i]>max)
{
max=array1[i];
}
if(array2[i]>max)
{
max=array2[i];
}
}
printf("
The MOS is: ");
for(i=0;i<1;i++)
{
if(max==array1[i])
{
printf("%s
",t1[i].name);
}
if(max==array2[i])
{
printf("%s
",t2[i].name);
}
}
return 0;
}
int main()
{
struct playearst1 t1[11];
struct playearst1 t2[11];
int i,p,n,j;
printf("
!!! 1st Team Info:
");
for(i=0; i<1; i++) ///you can use any number of players here
{
printf("Please Enter %d Player Name:
",i+1);
fflush(stdin);
gets(t1[i].name);
printf("Please Enter The Country Name:
");
gets(t1[i].country);
for(j=0; j<3; j++)
{
printf("Please Enter The Runs in Match %d
",j+1);
scanf("%d",&t1[i].run[j]);
}
for(j=0; j<3; j++)
{
printf("Please Enter The wickets in Match %d
",j+1);
scanf("%d",&t1[i].wicket[j]);
}
point1(t1,i);
for(j=0; j<3; j++)
{
printf("Points : %d",t1[i].points[j]);
}
}
printf("
!!! 2nd Team Info:
");
for(i=0; i<1; i++) ///you can use any number of players here
{
printf("Please Enter %d Player Name:
",i+1);
getchar();
gets(t2[i].name);
printf("Please Enter The Country Name:
");
gets(t2[i].country);
for(j=0; j<3; j++)
{
printf("Please Enter The Runs in Match %d
",j+1);
scanf("%d",&t2[i].run[j]);
}
for(j=0; j<3; j++)
{
printf("Please Enter The wickets in Match %d
",j+1);
scanf("%d",&t2[i].wicket[j]);
}
point2(t2,i);
for(j=0; j<3; j++)
{
printf("Points : %d",t2[i].points[j]);
}
}
MOM(t1,t2); ///for finding man of the match
MOS(t1,t2); ///for finding man of the series
return 0;
}
Add your comment