Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int points[2][3];
- struct player
- {
- char name[20], country[20];
- int runs[3][3], wickets[3][3];
- };
- int main()
- {
- struct player p[3];
- char line[20];
- for(int i=0; i< 2 ; i++)
- {
- printf("Player %d name :\n",i+1);
- scanf("%s",p[i].name);
- printf("Player %d country :\n",i+1);
- scanf("%s",p[i].country);
- printf("Player %d runs :\n",i+1);
- for(int j=0 ; j<3 ; j++)
- {
- printf("Enter the run of match no. %d : ",j+1);
- scanf("%d",&p[i].runs[i][j]);
- }
- printf("Player %d wickets :\n",i+1);
- for(int j=0 ; j<3 ; j++)
- {
- printf("Enter the wicket of match no. %d - ",j+1);
- scanf("%d",&p[i].wickets[i][j]);
- }
- printf("\n\n");
- }
- calculate_point(p);
- }
- void calculate_point(struct player p[])
- {
- for(int i=0; i<2; i++)
- {
- for(int j=0; j<3; j++)
- {
- points[i][j] = points[i][j] + p[i].wickets[i][j]*12;
- if(p[i].runs[i][j]<=25)
- points[i][j] = points[i][j] + 5;
- else if(p[i].runs[i][j] && p[i].runs[i][j]<=50)
- points[i][j] = points[i][j] + 10;
- else if(p[i].runs[i][j]>50 && p[i].runs[i][j]<=75)
- points[i][j] = points[i][j] + 15;
- else
- points[i][j] = points[i][j] + 20;
- }
- }
- findMoM_MoS(p);
- }
- void findMoM_MoS(struct player p[])
- {
- int cnt =0;
- for(int j=0; j<3; j++)
- {
- printf("Match %d:\n",j+1);
- printf("%s points : %d\n",p[0].name,points[0][j]);
- printf("%s points : %d\n",p[1].name,points[1][j]);
- if(points[0][j]>= points[1][j])
- {
- printf("MoM : %s\n",p[0].name);
- cnt++;
- }
- else
- {
- printf("MoM : %s\n",p[1].name);
- }
- }
- if(cnt>=2)
- printf("\nMan of the Series : %s\n",p[0].name);
- else
- printf("\nMan of the Series : %s\n",p[1].name);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement