Is it possible to loop randomly
for example
for ( int i = 0; i<= 6 ; i++ )
I don't want i to acsend from 0 to 6
but i want it to get all numbers randomly
for example
first time r = 5 second time r = 2 and so on
until it gets all the seven numbers
sry for my terrible english :D
More interesting approach is to create random generator for index. You can read the simple theory of LGC here: http://codeabbey.com/index/wiki/random-numbers
You need to think thoroughly of constraints - for example for your case M would be 7 and A could be K*7 + 1, while C could be any number not divisible by 7, so:
1 2 3
M = 7;
A = rand() % 100000 * 7 + 1;
C = rand() % 100000 * 7 + rand() % 6 + 1;
would give you lots of variants.
This approach allows you to avoid using temporary array.