Advertisement
apl-mhd

struct

Nov 4th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.71 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. /*
  8.  * File:   main.cpp
  9.  * Author: antimatter
  10.  *
  11.  * Created on November 4, 2016, 9:23 PM
  12.  */
  13.  
  14. #include <cstdlib>
  15. #include <cstdio>
  16. #include <string>
  17.  
  18. using namespace std;
  19.  
  20. struct  player{
  21.  
  22.     char name[50];
  23.     char country[50];
  24.     int runs[3];
  25.     int wickets[3];
  26.     int points[3];
  27.  
  28. };
  29.  
  30. void playrsDetails(struct player playerIndex[50]){
  31.  
  32.     int i,j, mofMathc=0, index;
  33.  
  34.      for(i = 0; i<1; i++){
  35.  
  36.         printf("Player's Name: ");
  37.         gets(playerIndex[i].name);
  38.  
  39.         printf("\nPlayer's Country: ");
  40.         gets(playerIndex[i].country);
  41.  
  42.         printf("\n");
  43.  
  44.         /*Run Input section */
  45.  
  46.         for(j=0; j<3; j++){
  47.             printf("%d match run:",j+1);
  48.             scanf("%d", &playerIndex[i].runs[j]);
  49.  
  50.             if(playerIndex[i].runs[j]<25){
  51.                  playerIndex[i].points[j] = 0 ;
  52.             }
  53.  
  54.             if(playerIndex[i].runs[j]>=25 && playerIndex[i].runs[j]<50 ){
  55.                  playerIndex[i].points[j] = 5 ;
  56.             }
  57.              if(playerIndex[i].runs[j]>=50 && playerIndex[i].runs[j]<75 ){
  58.                  playerIndex[i].points[j] = 10;
  59.             }
  60.             if(playerIndex[i].runs[j]>=75 && playerIndex[i].runs[j]<100 ){
  61.                  playerIndex[i].points[j] = 15 ;
  62.             }
  63.  
  64.              if(playerIndex[i].runs[j]>=100){
  65.                  playerIndex[i].points[j] = 20 ;
  66.             }
  67.  
  68.  
  69.  
  70.         }
  71.           printf("\n");
  72.  
  73.           /*****************wickets input***********************/
  74.           /*_____________________________________________________*/
  75.  
  76.          for(j=0; j<3; j++){
  77.             printf("%d match wickets:",j+1);
  78.             scanf("%d", &playerIndex[i].wickets[j]);
  79.  
  80.             if(playerIndex[i].wickets[j] > 0){
  81.                 playerIndex[i].points[j] += playerIndex[i].wickets[j]*12  ;
  82.             }
  83.  
  84.         }
  85.  
  86.           printf("\n\n\n");
  87.  
  88.     }
  89.      
  90.      
  91.      
  92. //    for(i=0;i<1; i++){
  93.        
  94. //        for(j =0; j<3; j++){
  95.            
  96. //            if(playerIndex[i].wickets[j] > mofMathc){
  97.                    
  98. //                mofMathc = playerIndex[i].wickets[j];
  99. //                index = i;
  100. //        }
  101.      
  102. //    }
  103.        
  104.        
  105. //    }
  106.  
  107.  
  108. }
  109.  
  110.  
  111. /*
  112.  *
  113.  */
  114. int main(int argc, char** argv) {
  115.       int i,j;
  116.     struct player playerIndex[50];
  117.  
  118.     playrsDetails(playerIndex);
  119.  
  120.  
  121.  
  122.     for(i =0; i<1; i++){
  123.  
  124.         for(j =0; j<3; j++){
  125.  
  126.              printf("%d match point = %d\n",j+1, playerIndex[i].points[j]);
  127.         }
  128.  
  129.     }
  130.  
  131.     return 0;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement