Hello. I need to reproduce this pattern using one main for loop and one nested for loop. I cannot seem to figure out the right way to do this. I came close, but not close enough.
0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

for (int x = 0; x < 10; x++)
 		{
 			for (int y = 0; y < x; y++)
 			{
 				System.out.print(y);
 			}
 			System.out.println();
 		}

I would use an array of ints. Then loop through the length of the array. Then the nested loop output the numbers from the end of the array back to the beginning using the first loop as the counter to denote how many elements need printing.

0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

code for this is
///

public class looping 
       {
          public static void main(String args[])
       {
          for (int x =0;  x <10; x++)
	   {
	      for (int y =x; y >=0; y--)
	   {
	      
	   	  System.out.print(y);
	   }
          System.out.println();
	   
	   }
       }
       }

/////

Edited 5 Years Ago by peter_budo: Adding code tags to old post

If you have question create new thread don't try to hijack one from 2007.
Read the notice at the top of the Java forum main page "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."
So do some work and if you get stuck start a new thread. Don't even think of starting a post with "i need to create a program..." if you don't want a torrent of sarcasm & abuse.

Edited 5 Years Ago by JamesCherrill: n/a

This question has already been answered. Start a new discussion instead.