problem in pyramid of number in java
I have a problem on how to make this output:
Output1:
ENTER NO.OF ROW/S: 5
1112131415
78910
456
23
1
Output2:
ENTER NO.OF ROW/S: 4
78910
456
23
1
I created a code below, but the output is like this:
Output1:
ENTER NO.OF ROW/S: 5
12345
6789
101112
1314
15
Output2:
ENTER NO.OF ROW/S: 6
123456
7891011
12131415
161718
1920
21
Code:
Scanner in=new Scanner(System.in);
int x,y,row,num=0;
System.out.print("ENTER NO.OF ROW/S:");
row=in.nextInt();
for(x=1;x<=row;x++)
{
for(y=x;y<=row;y++)
{
num++;
System.out.print(num);
}
System.out.println();
}
I'm newbie in java programming, what should I do to make that output possible? thanks in advance.
Re: problem in pyramid of number in java
Please only post a question once. This question has been answered in the other post.
Re: problem in pyramid of number in java
Thread locked. Duplicate of http://www.javaprogrammingforums.com...d-numbers.html
Please read the forum rules.