Results 1 to 11 of 11

Thread: Soccer tournament, partitioning games

Threaded View

  1. #4
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    This is the c code for doing it the analytical way.
    Sorry, source code have no comments.

    Code:
    //This program is trying to solve soccer team combination problem for troplosti.
    #include <iostream.h>
    #include <stdlib.h>
    #include <stdio.h>
    //Number of combinations for 4 teams= 4*3/2 = 6
    int main()
    {
          char array[4]={'A','B','C','D'};
    
          for(int cnt=0;cnt<4;++cnt)
          {
              printf("%c %c\n",array[0],array[1]);
              char swap=array[0];
              array[0]=array[1];
              array[1]=array[2];
              array[2]=array[3];
              array[3]=swap;
          }
          for(int cnt=0;cnt<2;++cnt)
          {
              printf("%c %c\n",array[cnt],array[cnt+2]);
          }
          system("PAUSE");
          
          return 0;
    }
    below is the output,
    ===============
    A D
    B A
    C B
    D C
    A C
    B D
    Last edited by transcendental; Jul 26th, 2002 at 04:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width