Advertisement
Mostafizur_Rahman

Untitled

Jun 8th, 2021
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.05 KB | None | 0 0
  1. #include<stdio.h>
  2. int points[2][3];
  3. struct player
  4. {
  5.  
  6.     char name[20], country[20];
  7.     int runs[3][3], wickets[3][3];
  8.  
  9. };
  10. int main()
  11. {
  12.     struct player p[3];
  13.     char line[20];
  14.     for(int i=0; i< 2 ; i++)
  15.     {
  16.         printf("Player %d name :\n",i+1);
  17.         scanf("%s",p[i].name);
  18.         printf("Player %d country :\n",i+1);
  19.         scanf("%s",p[i].country);
  20.         printf("Player %d runs :\n",i+1);
  21.         for(int j=0 ; j<3 ; j++)
  22.         {
  23.             printf("Enter the run of match no. %d : ",j+1);
  24.             scanf("%d",&p[i].runs[i][j]);
  25.         }
  26.         printf("Player %d wickets :\n",i+1);
  27.         for(int j=0 ; j<3 ; j++)
  28.         {
  29.             printf("Enter the wicket of match no. %d - ",j+1);
  30.             scanf("%d",&p[i].wickets[i][j]);
  31.         }
  32.         printf("\n\n");
  33.     }
  34.     calculate_point(p);
  35. }
  36. void calculate_point(struct player p[])
  37. {
  38.     for(int i=0; i<2; i++)
  39.     {
  40.         for(int j=0; j<3; j++)
  41.         {
  42.             points[i][j] = points[i][j] + p[i].wickets[i][j]*12;
  43.  
  44.             if(p[i].runs[i][j]<=25)
  45.                 points[i][j]  = points[i][j] + 5;
  46.  
  47.             else if(p[i].runs[i][j] && p[i].runs[i][j]<=50)
  48.                 points[i][j]  = points[i][j] + 10;
  49.  
  50.             else if(p[i].runs[i][j]>50 && p[i].runs[i][j]<=75)
  51.                 points[i][j]  = points[i][j] + 15;
  52.  
  53.             else
  54.                 points[i][j]  = points[i][j] + 20;
  55.  
  56.         }
  57.     }
  58.     findMoM_MoS(p);
  59. }
  60.  
  61. void findMoM_MoS(struct player p[])
  62. {
  63.  
  64.     int cnt =0;
  65.     for(int j=0; j<3; j++)
  66.     {
  67.         printf("Match %d:\n",j+1);
  68.         printf("%s points : %d\n",p[0].name,points[0][j]);
  69.         printf("%s points : %d\n",p[1].name,points[1][j]);
  70.         if(points[0][j]>= points[1][j])
  71.         {
  72.             printf("MoM : %s\n",p[0].name);
  73.             cnt++;
  74.         }
  75.         else
  76.         {
  77.             printf("MoM : %s\n",p[1].name);
  78.         }
  79.     }
  80.     if(cnt>=2)
  81.         printf("\nMan of the Series : %s\n",p[0].name);
  82.     else
  83.         printf("\nMan of the Series : %s\n",p[1].name);
  84.  
  85. }
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement