Results 1 to 17 of 17
Thread: Triangle using Numbers
- 06-04-2010, 06:39 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
- 06-04-2010, 06:49 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
You're welcome.Java Code:System.out.println(" 1"); System.out.println(" 2 2"); System.out.println(" 3 3 3"); System.out.println(" 4 4 4 4"); System.out.println("and so on....");
kind regards,
Jos
- 06-04-2010, 07:38 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
Hello Jos,
Thank You for the reply, but i wasn't expecting this....Anyways this is the code i hav written
public class Triangle
{
public static void main(String[] args)
{
int n = Integer.parseInt(args[0]);
for(int i=1;i<=n;i++)
{
for(int j=n;j>=i;j--)
{
System.out.print(" ");
}
for(int k=1;k<=i;k++)
{
System.out.print(i+" ");
}
System.out.println("");
}
}
}
but i wanna give more spaces...can u give me a hint
Thanks n Regards
Anand
- 06-04-2010, 07:56 PM #4
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Woo
What about this one :rolleyes:
void gogo(int limit){
for(int i=0; i<limit; i++)
{
for(int j=0; j<i+1; j++)
{
System.out.print(i+1);
}
System.out.println();
}
}If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 06-04-2010, 08:01 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 06-04-2010, 08:05 PM #6
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-04-2010, 08:12 PM #7
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-04-2010, 08:14 PM #8
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Where do you want to put more spaces? What is it doing now and what do you want it to be doing?
- 06-04-2010, 08:20 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 06-04-2010, 08:37 PM #10
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-04-2010, 09:04 PM #11
Hey everyone
Looks like this thread is about having a laugh or two. ;) Seriously, this is a textbook problem. :p
Have fun guys
TimLast edited by tim; 06-04-2010 at 09:51 PM.
Eyes dwelling into the past are blind to what lies in the future. Step carefully.
- 06-04-2010, 09:11 PM #12
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 06-05-2010, 03:50 PM #13
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
Hope u guys r having fun....but pls execute my code n then gimme a suggestion..
- 06-05-2010, 03:55 PM #14
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
Hello,
Now its displaying a Equilateral Triangle using no's, but i want to give a tab space b/w the no's...the o/p am expecting is not visible exactly, so pls execute the program n let me know...n if i give number above 9 the triangular structure ll be destroyed...
Thanks n Regards
Anand
- 06-05-2010, 03:59 PM #15
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 06-05-2010, 04:04 PM #16
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
- 06-05-2010, 04:10 PM #17
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
ASCII Triangle
By physics in forum New To JavaReplies: 2Last Post: 03-13-2010, 01:00 AM -
Triangle
By jkswebsite in forum New To JavaReplies: 8Last Post: 01-10-2009, 02:08 PM -
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10-14-2008, 11:46 PM -
Is it a right triangle? (Code help)
By TheApostle in forum New To JavaReplies: 8Last Post: 10-07-2008, 08:39 PM -
Pascal Triangle help
By Magic101 in forum New To JavaReplies: 4Last Post: 05-01-2008, 07:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks