- 3
Guys I need help I have homework and the dr wants A pyramid of numbers like this. 1\n 212\n 32123 , \n means new line
Deadline will finish at 11:30 PM
14 Antworten
+ 13
x _6rd please show your tried code so we can help you out though the problem and give you feedback or improvement points over your code problem. If we directly sent you solution you won't be learn much so please attach an try of your code which is minimum execution of your problem which you able to do till now.
+ 9
x _6rd an way to acheive your task I just simplified the loop in two stages so you will understand easily about the problem occuring with the loop used by you. Just try to implement your version and loop by seeing this code.
https://code.sololearn.com/cyUKlIzgmqTI/?ref=app
+ 1
I think this code will help you. This program is written in C ++
https://code.sololearn.com/cvPfpXqRAbwk/?ref=app
+ 1
Thank you so much I really appreciate that you save my life
0
Plz guys
0
Scanner input = new Scanner(System.in);
System.out.println("enter number of rows at most 20: ");
int rows = input.nextInt();
if(rows<=20) {
for(int i = 0 ; i<=rows; i++) {
for(int j = 20; j>i;j--) {
System.out.print(" ");
}
for(int j = 0 ; j<i*2+1; j++) {
System.out.print( i+1);
}
System.out.println();
}
}
else
System.out.println("erorr input");
0
This code I do it and it is almost the answer but it's need some edits
0
Your second loop is wrong.
You have to count down from i to 1 and then up to i again.
Use two loops for that
0
This loop is for space it forms the pyramid
0
I think the wrong is in loop 3 but I don't know how to solve it 💔
0
This code give this form
1
222
3333
44444
555555
But it is shape such as pyramid
0
I need like this shape but in different values
0
It is working I have no words enough to thank uuu❤️
0
This is the code,check it
import java.util.Scanner;
class Demo
{
public static void main (String[] args)
{
System.out.println("Enter the no. of rows");
Scanner a =new Scanner(System.in);
int r= a.nextInt();
int i,j,k,l;
for(i=1;i<=r;i++)
{
for(j=i;j<r;j++)
{
System.out.print(" ");
}
for(k=i;k>1;k--)
{
System.out.print(k);
}
for(l=1;l<=i;l++)
{
System.out.print(l);
}
System.out.println();
}
}
}