This is the c code for doing it the analytical way.
Sorry, source code have no comments.
below is the output,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; }
===============
A D
B A
C B
D C
A C
B D




Reply With Quote