0
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#define p printf
#define s scanf

int total( int q, int w);
void gemar(void);
void gem(void);
int setfunction (int *team1score,int *team2score);


      static int team1score_set1  ;
      static int counter1_set1 = 0;
      static int team2score_set1 ;
      static int counter2_set1 = 0;
      static int team1score_set2  ;
      static int counter1_set2 = 0;
      static int team2score_set2 ;
      static int counter2_set2 = 0;
      static int team1score_set3 ;
      static int counter1_set3 = 0;
      static int team2score_set3 ;
      static int counter2_set3 = 0;
      static char team1name[10];
      static char team2name[10];    

main()
      {

p ("WELCOME TO VOLLEYBALL STATISTICS\n\n\n");
p ( "\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
p ("\n*\t\t\t\t\t\t\t\t\t*");
p ("\n*\tLegend :\t\t\t\t\t\t\t*");
p ("\n*\t\t\t\t\t\t\t\t\t*");                                                                                                                                                               
p ( "\n*\t[A] Ace \t[B] Block \t[E] Error\t[K] Kill\t*");
p ("\n*\t\t\t\t\t\t\t\t\t*");
p ( "\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");

p ( "\n\nInput Team 1 Name : " );
s ( "%s",team1name);
p ( "\nInput Team 2 Name : " );
s ( "%s",team2name) ;
      p("\nPress any key to begin set 1");
      getch();
      system("cls");

      setfunction(&team1score_set1,&team2score_set1);
      if( team1score_set1 > team2score_set1)
          {
          p("\n\nThe winner for set 1 is Team %s",team1name);
          counter1_set1++;
          }
      else if( team2score_set1 > team1score_set1)
               {
               p("\n\nThe winner for set 1 is Team %s",team2name);
               counter2_set1++;
               }

      gem();
      p ( "\nPress any key to begin set 2 " );
      getch();
      system ("cls");
      setfunction(&team1score_set2,&team2score_set2);
      if (team1score_set2 > team2score_set2)
                          {
                          p("\n\nThe winner for set 2 is Team %s",team1name);
                          counter1_set2++;
                          }
      else if (team2score_set2 > team1score_set2)
                          {
                          p("\n\nThe winner for set 2 is Team %s",team2name);
                          counter2_set2++;
                          }
      gem();
      if ( total(counter1_set1,counter1_set2)==2 && total(counter2_set1,counter2_set2)==0)
         {
         p("\nWe have a winner... and the winner is Team %s",team1name);
         getch();
         }
      else if ( total(counter1_set1,counter1_set2)==0 && total(counter2_set1,counter2_set2)==2)
              {
              p("\nWe have a winner... and the winner is Team %s",team2name);
              getch();
              }

      else 
              {
                      p ( "\nPress any key to begin set 3" );
                      getch();
                      system ("cls");
                      setfunction(&team1score_set3,&team2score_set3);
                      if ( team1score_set3 > team2score_set3 )
                           {
                           p("\n\nThe winner for set 3 is Team %s",team1name);
                           counter1_set3++;
                           }
                      else if ( team2score_set3 > team1score_set3 )
                           {
                           p("\n\nThe winner for set 3 is Team %s",team1name);
                           counter2_set3++;
                           }
               }

      gemar();
      if ( (counter1_set1 + counter1_set2 + counter1_set3 ) > (counter2_set1 + counter2_set2 + counter2_set3 )  )
         {
             p("\nWe have the overall winner ... and the winner is Team %s",team1name);
             getch();
         }
      else if ( (counter1_set1 + counter1_set2 + counter1_set3 ) > (counter2_set1 + counter2_set2 + counter2_set3 )  )
              {
                  p("\nWe have the overall winner ... and the winner is Team %s",team1name);
                  getch();
              }
      getch();
      }




int setfunction (int *team1score,int *team2score)        
{
char command;
char team1[15];
char team2[15];
char select;

int team1_block = 0;
int team1_kill = 0 ;
int team1_aces= 0;
int team1_error = 0;


int team2_block = 0;
int team2_kill = 0;
int team2_aces = 0;
int team2_error = 0;

*team1score = 0;
*team2score = 0;




*team1score = team1_block + team1_kill + team1_aces + team2_error;
*team2score = team2_block + team2_kill + team2_aces + team1_error; 

system("cls");
p("\nteam1 block is : %d\t team2 block is : %d",team1_block,team2_block);           
p("\nteam1 kill is  : %d \t team2 kill  is : %d",team1_kill,team2_kill);
p("\nteam1 aces is  : %d \t team2 aces  is : %d",team1_aces,team2_aces);
p("\nteam1 error is : %d \t team2 error is : %d\n",team1_error,team2_error);

p("\n%.5s is  : %d\t\t %.5s is : %d\n",team1name,*team1score,team2name,*team2score);       

p ( "\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
p ("\n*\t\t\t\t\t\t\t\t\t*");
p ("\n*\tLegend :\t\t\t\t\t\t\t*");
p ("\n*\t\t\t\t\t\t\t\t\t*");                                                                                                                                                               
p ( "\n*\t[A] Ace \t[B] Block \t[E] Error\t[K] Kill\t*");
p ("\n*\t\t\t\t\t\t\t\t\t*");
p ( "\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");

if ( *team1score >= 12  &&  *team1score > *team2score + 1  )
                {
                return 0;
                }
else if ( *team2score >= 12  &&  *team2score > *team1score + 1  )
                {
                return 0;
                }


      p ( "\n\nEnter Command  : " );
      s ("%s",&command);
      p ( "\nSelect team to input [A]Team1 [B]Team2 : " );
      s ( "%s", &select);


 {  
if ((command=='B'||command=='b')&&(select=='a'||select=='A'))
   {
   team1_block++;
   return setfunction (*team1score,*team2score); 
   }
else if ((command=='k'||command=='K')&&(select=='a'||select=='A'))
     {
     team1_kill++;
      return setfunction (*team1score,*team2score);
     }
else if ((command=='a'||command=='A')&&(select=='a'||select=='A'))
     {
     team1_aces++;
     return setfunction (*team1score,*team2score);
     }
else if ((command=='E'||command=='e')&&(select=='a'||select=='A'))
     {
     team1_error++;
      return  setfunction (*team1score,*team2score);
     }

                  else if ((command=='B'||command=='b')&&(select=='B'||select=='b'))
                  {
                  team2_block++;
               return setfunction (*team1score,*team2score);
                  }
                  else if ((command=='k'||command=='K')&&(select=='B'||select=='b'))
                  {
                  team2_kill++;
                  return setfunction (*team1score,*team2score);
                  }
                  else if ((command=='a'||command=='A')&&(select=='B'||select=='b'))
                  {
                  team2_aces++;
                  return  setfunction (*team1score,*team2score);
                  }
                  else if ((command=='E'||command=='e')&&(select=='B'||select=='b'))
                  {
                  team2_error++;
                 return  setfunction (*team1score,*team2score);

                  } 


}
}

int total( int q,int w)
    {
    int result = 0;
    result = q + w ;
    return result;
    }
void gemar(void)
{
p ( "\n\n.---------------------------------,");
p ( "\n|    TEAM    | SET1 | SET2 | SET3 |" );  
p ( "\n|            |      |      |      |" );  
p ( "\n|---------------------------------|" );  
p ( "\n|  Amerimnok |  %d  |  %d  |  %d  |" ,team1score_set1,team1score_set2,team1score_set3);    
p ( "\n|            |      |      |      |" );        
p ( "\n|---------------------------------|" ); 
p ( "\n|  Brazillan |  %d  |  %d  |  %d  |",team2score_set1,team2score_set2,team2score_set2);   
p ( "\n|            |      |      |      |" );        
p ( "\n`---------------------------------'" );    
getch();     
}

void gem(void)
{
p ( "\n\n,------------------------------,");
p ( "\n|    TEAM    | SET1| SET2| SET3|" );  
p ( "\n|            |     |     |     |" );  
p ( "\n|------------------------------|" );  
p ( "\n|    Team 1  |  %d  |  %d  |  %d  |",counter1_set1,counter1_set2,counter1_set3);    
p ( "\n|            |     |     |     |" );        
p ( "\n|------------------------------|" ); 
p ( "\n|    Team 2  |  %d  |  %d  |  %d  |",counter2_set1,counter2_set2,counter2_set3);   
p ( "\n|            |     |     |     |" );        
p ( "\n`------------------------------'" );    
getch();     
}
3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by I_m_rude
0

Code is really awesome to see! ;) as much I have experienced, dev c++ gives that error when you are using too much memory or secondly, when there is segmentaion fault. Try to catch that two if there is any because understanding what you trying to do in this code is really time consuming for anybody. thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.