1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
int solution [9][9]={{6,2,1,3,7,8,4,9,5},
{7,8,3,5,9,4,6,1,2},
{5,4,9,2,6,1,8,3,7},
{1,6,4,7,5,9,2,8,3},
{3,7,8,4,2,6,9,5,1},
{9,5,2,8,1,3,7,6,4},
{2,9,6,1,3,7,5,4,8},
{4,1,5,9,8,2,3,7,6},
{8,3,7,6,4,5,1,2,9}};
int permutation [9][9]={};
double N,N2;
int N1,N3;
srand(time(0));
N=0;
do
{
N=((double)(rand())/(double)(RAND_MAX));
N1=N+1;
printf("%i",N1);
N2=((double)(rand())/(double)(RAND_MAX));
N3=N2+1;
printf("%i",N3);
}while(N1==N3);
// PERMUTATION COLONNE
for(J=0;J<9;J++)
{
for(I=0;I<9;I++)
{
permutation[I][J]=solution[I][N1];
solution[I][N1]=solution[I][N2];
solution[I][N2]=permutation[I][J];
}
}
printf(" 0 1 2 3 4 5 6 7 8\n ");
printf(" ^ ^ ^ ^ ^ ^ ^ ^ ^\n ");
printf(" ^ ^ ^ ^ ^ ^ ^ ^ ^\n ");
printf("\n");
for(I=0;I<=8;I++)
{
printf("%i>>",I);
for(J=0;J<=8;J++)
{
if(solution[I][J]==0)
Color(12,0);
printf("%3d ",solution[I][J]);
Color(15,0);
if(J==2 || J==5) printf("|");
}
printf("\n");
if(I==2 || I==5)
printf(" \n ===========================================");printf("\n"); printf("\n");
}
system("pause"); |
Partager