برنامه نویسی

#include
#include
#include
#include
void mat(void);
int tedad_teem=2;
int bazi_DR_rpze;
int yek_doreh;
int tedad_bazi;
int x[20][20];
int n;
int i,j,z;

void main (void)
{

scanf("%d",&tedad_teem);
tedad_bazi=tedad_teem*(tedad_teem-1)/2;
bazi_DR_rpze= tedad_teem/2;
yek_doreh= tedad_teem-1;
printf("\ntedad_teem=%d",tedad_teem);
printf("\nbazi_DR_rpze=%d",bazi_DR_rpze);
printf("\nyek_dore=%d",yek_doreh);
printf("\ntedad_bazi=%d",tedad_bazi);
printf("\n");


for(int i=1;i<=tedad_teem;i++)
for(int j=1;j<=yek_doreh;j++)
if(x[i][j]==0)
mat();


for( i=1;i<=tedad_teem;i++)
{printf("\n");
for(int j=1;j<=yek_doreh;j++)
printf("%d  ",x[i][j]);}

}

void mat (void)
{
  int num=0;
for(int i=1;i<=tedad_teem;i++)

 for(int j=1;j<=yek_doreh;j++)
 {p1:
 num+=1;

 n=random(tedad_teem)+1;
 //if(n>0 && n<=tedad_teem)
 //scanf("%d",&n);
         for(int z=1;z<=yek_doreh;++z)
         if(x[i][z]==n)
         goto p1;

 if(x[i][j]==0 && x[n][j]==0)
 if(i!=n)
 {x[i][j]=n;
 x[n][j]=i;
  }
 else
 goto p1;
 printf("\n%dteem:%d day:%d  teem2:%d",num,i,j,x[i][j]);
 }

}

+ نوشته شده در  پنجشنبه یکم مرداد ۱۳۸۸ساعت 18:33  توسط ابراری |