Here is the question what I translated. My translate is bad hope you will understand.
Show every triplet(x,y,z) where x <= A, y <= B, z <= C (0 <= A, B, C <= 20) and show x,y and z small to large.
input:
input files first line will give test case's number (t <= 20). After this on the number of line T there are theree number A ,B,C.
Output:
For Every case begainning the case number print "Case X :" Where case is 1 to T. Then print every tripolet small to large. Tripolet's are arranged by lexicographical sequence .
N.B : Lexicographic sequence - a tripolet (a1,b1,c1) another tripolet (a2,b2,c2) will be smaller by Lexicographic sequence and if the condition is true what given here : (i) a1 < a2 (ii) a1 = a2 and b1 < b2 (iii) a1 = a2 and b1 = b2 and c1 < c2 .
Input :
3
1 1 2
3 2 3
4 4 4
Output:
Case 1:
0 1 2
Case 2:
0 1 2
0 1 3
0 2 3
1 2 3
Case 3:
0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4
What I have tried:
int main()
{
int T, i, j, A, B, C, temp = 0;
scanf("%d",&T);
while(T--) {
scanf("%d %d %d",&A,&B,&C);
for(i = 0;i < 3;i++) {
if(A > B) {
temp = A;
A = B;
B = temp;
}
else if (A > C) {
temp = A;
A = C;
C = temp;
}
else if(B > C) {
temp = B;
B = C;
C = temp;
}
}
I can't figure out the algorithm. but I tried some.
First, I sequence small to large by bubble shoot. Then I can't understand what I should (second step - lexicographic sequence). Even I don't know, is it wright way? or not?