14,237,722 members
Rate this:
See more:
i need a combination like this
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5 6   8
1 2 3 4 5   7 8
1 2 3 4   6 7 8
1 2 3   5 6 7 8
1 2   4 5 6 7 8
1   3 4 5 6 7 8

For next iteration
1 2 3 4 5 6 7
1 2 3 4 5 6     9
1 2 3 4 5   7   9
1 2 3 4   6 7   9
1 2 3   5 6 7   9
1 2   4 5 6 7   9
1   3 4 5 6 7   9

like wise till
1   3 4 5 6 7 8
1   3 4 5 6 7   9
1   3 4 5 6   8 9
1   3 4 5   7 8 9
1   3 4   6 7 8 9
1   3   5 6 7 8 9
1     4 5 6 7 8 9

What I have tried:

Posted
Updated 7-Feb-17 21:59pm
Peter Leow 8-Feb-17 1:09am

"I have tired but not getting the logic" then show what you have tried.
OriginalGriff 8-Feb-17 1:59am

What have you tried?
Where are you stuck?
What help do you need?

Rate this:

## Solution 1

Look at the digits arranged as a square
(1,1)                      (1,9)
\                         /
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
1  2  3  4  5  6  7  8  9
/                         \
(9,1)                      (9,9)

Then at iteration k you must show all the square items, but:
• The ones of column k, that is (i,k).
• The ones on the diagonal, that is (k, 10-k).
Rate this:

## Solution 2

Quote:
You have noted that
You don't understand the logic:
- try to draw by hand the result wanted for each iteration in order.
- try to analyze the differences between each iteration an note what t(he changes are.
By this point, you should have got the logic, otherwise, talk to your teacher.

are you sure about the 9 in first iteration ?
Rate this:

## Solution 3

#include<stdio.h>

int main()
{
int a[9]={1,2,3,4,5,6,7,8,9};
int i,j=9,k;

while(j>0)
{
for(i=1;i<8;i++)
{
for(k=0;k<9;k++)
{
if(k!=i&&k!=j)
{
printf("%d",a[k]);

}
else
{
printf(" ");
continue;
}
}
printf("\n");
}
printf("\n");
j--;
}
return 0;
}
Patrice T 8-Feb-17 4:08am

A question and a solution without a single sentence!
Is it your solution or code that don't work ?
R!sh! 8-Feb-17 4:14am

my solution. :)
Patrice T 8-Feb-17 4:17am

So, use Accept answer (near "Solution 3") to signal it's solved and to close the question.
R!sh! 17-Feb-17 0:18am

R!sh! 8-Feb-17 4:14am

finally i did it. :D
Patrice T 8-Feb-17 11:35am

I see that your program do not match the example of the question, first iteration is not the same (the 9 on first line).
R!sh! 16-Feb-17 23:55pm

it is coming in reverse order.