[Cpp]
# Include <time. h>
# Include <stdlib. h>
# Include <iostream>
# Include <string. h>
# Include <cstdio>
Using namespace std;
Double random ()
{Return (double) rand ()/RAND_MAX ;}
Int random (int m)
{
Return (int) (random () * (m-1) + 0.5 );
}
Int n, m;
Void in (int &)
{
Char ch;
While (ch = getchar () <'0' | ch> '9 ');
For (a = 0; ch> = '0' & ch <= '9'; ch = getchar () a = a * 10 + ch-'0 ';
}
Int main ()
{
Srand (time (NULL ));
Int T;
In (T );
Freopen ("1.txt"," w ", stdout );
Printf ("% d \ n", T );
While (T --)
{
In (m), in (n );
Printf ("% d \ n", m );
For (int I = 0; I! = M; ++ I) // m indicates the number of groups and n indicates the data range.
[Cpp] view plaincopy
{
Int x;
Int y;
Bool flag = false;
If (rand () % 2) flag = true;
While (1)
{
X = random (n) + 1;
Y = random (n) + 1;
If (x! = Y & x & y) break;
}
If (I % 2 = 1 & flag) x =-x, y =-y;
Else if (I % 2 = 1 &&! Flag) x =-x;
Else if (I % 2 = 0 & flag) y =-y;
Printf ("% d \ n", x, y );
}
} Return 0;
By smallacmer