> Confusing Programming Problem?

Confusing Programming Problem?

Posted at: 2014-12-18 
Don't know what language you are using, but you would use 2 nested loops

the i loop counting from 10 down to 1

the nested j loop would output i for i times

10 would be a special case, might require an if 10 than output 0

or an output last character each time to strip the leading 1.

Brilliant moves has brilliantly solved it in Java.

Loop condition will remain same in all languages, only syntax will differ.

Nested loops. Google should help

The questioner has already solved this one; for a look at an easy solution in

C, see http://pastebin.com/1UUqqi28 under the name numbs.c

>

> John (gnujohn@gmail.com)

for(int i=10; i>=1; i--)

{

for(int x=1; x<=i; x++)

print i%10

}

}

for (int i=10; i>=1; i--) {

for (int j=1; j<=i; j++) {

System.out.print(i%10);

} // end for j

System.out.println(); // new line

} // end for i

here is the logic:

int j,k;

for(j=10;j>=0;j--){

for(k=j;k>0 ;k--)

cout << j%10;

cout << endl;

}

Use for repetition statements and increment/decrement operators to produce the output.

0000000000

999999999

88888888

7777777

666666

55555

4444

333

22

1

It will decrement, but do not know how to go ahead