Results 1 to 3 of 3
Thread: Triangle Pattern with numbers
- 06-05-2011, 06:16 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 12
- Rep Power
- 0
Triangle Pattern with numbers
Hi I'm trying to do a triangle pattern, I've done this before but I'm really lost for how to do it with incrementing numbers.
e.g.,
1
12
123
1234
...
Java Code:public static void drawPattern(int n) { // loop N times, one for each row for (int i = 0; i < n; i++) { // print j * for (int j = 0; j < i; j++) System.out.print("*"); // print a new line System.out.println(); }
Could someone give me a heads up on how I could change this code to make it with numbers?
Any information would be greatly appreciated!
- 06-05-2011, 06:41 PM #2
Change the "*" to be the number you want.
Last edited by Norm; 06-05-2011 at 06:45 PM.
- 06-05-2011, 07:27 PM #3
Member
- Join Date
- Jun 2011
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Star triangle pattern
By crazy4fun in forum New To JavaReplies: 7Last Post: 03-06-2011, 01:03 PM -
strategy pattern and bridge pattern
By jomypgeorge in forum New To JavaReplies: 2Last Post: 12-13-2010, 05:13 AM -
Triangle using Numbers
By Anandt88 in forum New To JavaReplies: 16Last Post: 06-05-2010, 04:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks