SOLIDKSINGH
Programmer
ya it is skol problem......but i don't have much time i have hand it tomorrow....but i did got some code....plese see that .if u can improve ................this is for 6 players and 32 week..........but have to make it in general.......
plese see this code.......
thanks....
#include<iostream.h>
#include<cstdlib>
#include<iomanip.h>
int main()
{
int p1,p2,p3,p4,p5,p6,w1,w2,w3,w4,w5,w6;
int a[32][6]={0},p[6][6]={0};
for(int i=0;i<32;i++)
{
p1 = (rand() % 6+1);
while(1)
{
p2= (rand() % 6+1);
if(p1==p2)
continue;
else
break;
}
while(1)
{
p3 = (rand() % 6+1);
if(p1==p3||p2==p3)
continue;
else
break;
}
while(1)
{
p4 = (rand() % 6+1);
if(p1==p4||p2==p4||p3==p4)
continue;
else
break;
}
while(1)
{
p5 = (rand() % 6+1);
if(p1==p5||p2==p5||p3==p5||p4==p5)
continue;
else
break;
}
while(1)
{
p6 = (rand()% 6+1);
if(p1==p6||p2==p6||p3==p6||p4==p6||p5==p6)
continue;
else
break;
}
a[0]=p1;
a[1]=p2;
a[2]=p3;
a[3]=p4;
a[4]=p5;
a[5]=p6;
cout<<"week"<<i+1<<":"<<"("<<a[0]<<","<<a[1]<<"
"<<setw(5)<<"("
<<a[2]<<","<<a[3]<<"
"<<setw(5)<<"("<<a[4]<<","<<a[5]<<"
"<<endl;
}
for(int q=0;q<32;q++)
{
w1=a[q][0];
w2=a[q][1];
w3=a[q][2];
w4=a[q][3];
w5=a[q][4];
w6=a[q][5];
p[w1-1][w2-1]=p[w1-1][w2-1]+1;
p[w2-1][w1-1]=p[w2-1][w1-1]+1;
p[w3-1][w4-1]=p[w3-1][w4-1]+1;
p[w4-1][w3-1]=p[w4-1][w3-1]+1;
p[w5-1][w6-1]=p[w5-1][w6-1]+1;
p[w6-1][w5-1]=p[w6-1][w5-1]+1;
}
cout<<setw(7)<<"p1"<<setw(5)<<"p2"<<setw(6)<<"p3"<<setw(4)
<<"p4"<<setw(6)<<"p5"<<setw(5)<<"p6"<<endl;
for(int l=0;l<6;l++)
{
cout<<"p"<<l+1<<setw(5);
for(int d=0;d<6;d++)
cout<<p[l][d]<<setw(5);
cout<<endl;
}
return 0;
}
plese see this code.......
thanks....
#include<iostream.h>
#include<cstdlib>
#include<iomanip.h>
int main()
{
int p1,p2,p3,p4,p5,p6,w1,w2,w3,w4,w5,w6;
int a[32][6]={0},p[6][6]={0};
for(int i=0;i<32;i++)
{
p1 = (rand() % 6+1);
while(1)
{
p2= (rand() % 6+1);
if(p1==p2)
continue;
else
break;
}
while(1)
{
p3 = (rand() % 6+1);
if(p1==p3||p2==p3)
continue;
else
break;
}
while(1)
{
p4 = (rand() % 6+1);
if(p1==p4||p2==p4||p3==p4)
continue;
else
break;
}
while(1)
{
p5 = (rand() % 6+1);
if(p1==p5||p2==p5||p3==p5||p4==p5)
continue;
else
break;
}
while(1)
{
p6 = (rand()% 6+1);
if(p1==p6||p2==p6||p3==p6||p4==p6||p5==p6)
continue;
else
break;
}
a[0]=p1;
a[1]=p2;
a[2]=p3;
a[3]=p4;
a[4]=p5;
a[5]=p6;
cout<<"week"<<i+1<<":"<<"("<<a[0]<<","<<a[1]<<"
<<a[2]<<","<<a[3]<<"
}
for(int q=0;q<32;q++)
{
w1=a[q][0];
w2=a[q][1];
w3=a[q][2];
w4=a[q][3];
w5=a[q][4];
w6=a[q][5];
p[w1-1][w2-1]=p[w1-1][w2-1]+1;
p[w2-1][w1-1]=p[w2-1][w1-1]+1;
p[w3-1][w4-1]=p[w3-1][w4-1]+1;
p[w4-1][w3-1]=p[w4-1][w3-1]+1;
p[w5-1][w6-1]=p[w5-1][w6-1]+1;
p[w6-1][w5-1]=p[w6-1][w5-1]+1;
}
cout<<setw(7)<<"p1"<<setw(5)<<"p2"<<setw(6)<<"p3"<<setw(4)
<<"p4"<<setw(6)<<"p5"<<setw(5)<<"p6"<<endl;
for(int l=0;l<6;l++)
{
cout<<"p"<<l+1<<setw(5);
for(int d=0;d<6;d++)
cout<<p[l][d]<<setw(5);
cout<<endl;
}
return 0;
}