
Posted by
Arabaaaabbbaaa, 09-01-2010 13:11
main()
{
int width, height,points,i,j;
/*****************creating the points TABLE***************************/
cout <<
"The number must be INTEGER! (just like the contents NO. x )\n" "(The more you give, the longer it will take to calculate them)\n";
cout <<
"\n\nHow many points do you have?\n";
for (int w=
0 ; w<points ;w++
) // user gives the points {
cout <<
"NO." <<
(w+
1) <<
": ";
tablica[w]=a;
}
/*******************CREATING TABLE FOR ALL POSSIBILITIES*************/
height = (factorial(points));
width = (points);
int **tab =
new int*
[height
];
// double pointer for (int i =
0; i < height; i++
) {
}
i=0; j=0;
/*********************************************/
/********************FILLING******************/
/*********************************************/
for (j=
0 ; j < width ; j++
) //... and to the next column {
g=0;
/******fill column******/
for (i=
0 ; i < height ; i++
) {
/*** fill cell***/
for (int m=
0 ; m<
1 //check if the number repeats {
if (g>=points
){g=
0;
} // not to get out of table {
{
if (tablica
[g
] == tab
[i
][h
]) {z=1;} // z=1 - the number already
// exists
} // z=0 - go ahead, it's ok
}
{g++; z=0; /*if (g>points) g=0;*/}
}
/*****************now we know what to write. But where?*******/
/*********/
if ( i==
0 && j==
0){tab
[i
][j
] = tablica
[g
];
} // for 1st cell /*********/
else if (i &&
((i%
(factorial
(points-j-
1)))==
0)) // period {
g++;
/********/
for (int m=
0 ; m<
1 // period check {
{
{
if (tablica
[g
] == tab
[i
][h
]) {z=1;}
}
}
/*********/ else m++;
// get out of loop }
tab[i][j] = tablica[g];
}
/*********/
{tab[i][j] = tablica[g];}
}
}
/* ----------------------------------------------*/
/* ----------- DISPLAY OF THE TABLE -------------*/
/* ----------------------------------------------*/
cout <<
"\nThese are all the possibilities\n";
i=0 ;
while ( height - i
) //wyswietlamy cala tablice {
j=0;
{
cout << tab
[i
][j
] <<
"\t";
j++;
}
i++;
}
}// END OF PROGRAM
int factorial
(int number_f
) // function 1 {
for (int i=
1 ; i<=number_f ; i++
) {
wynik = wynik * i;
}
}
Your Name
Remember me
Syntax highlighting
Expire
Source code
Your browser does not support JavaScript. Please, enter this code in that field: BQRZCPCUGO:
Upload