+ 2

Please correct this so that the output is a heart

https://code.sololearn.com/c6xHJO8Ozgv5/?ref=app

24th Nov 2021, 11:23 AM
Rajdeep Singh
Rajdeep Singh - avatar
5 Antworten
+ 2
public class Prgrm { public static void main(String[] args) { int a = 12;int c= 1,p=1,q=7; for(int b= 3; b !=0; b--) { for( c = 1; c<= b ; c++) System.out.print(" "); for(int d = 1; d<= c*p+1; d++) System.out.print("*"); for(int e = q; e != 0; e--) System.out.print(" ") ; for(int f= 1; f<= c*p+1; f++) System.out.print("*"); p*=2; q-=2; System.out.println(); } System.out.print(" "); for(int i=0;i<10;i++) System.out.print("*"); System.out.print(" "); for(int i=0;i<10;i++) System.out.print("*"); System.out.println(); for (int i = 1; i <= a; i++) { for (int j = 1; j <= i; j++) System.out.print(" "); for (int d= 1; d <= a-i; d++) System.out.print("* ") ; System.out.println();
24th Nov 2021, 12:13 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
+ 2
Ok thanks
24th Nov 2021, 12:15 PM
Rajdeep Singh
Rajdeep Singh - avatar
+ 1
Rajdeep Singh If you can find a way to adjust the space in the second section it would look better. Hope you got some ideas in the first loop..
24th Nov 2021, 12:14 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
+ 1
Actually I want to ask u what change u made
24th Nov 2021, 12:18 PM
Rajdeep Singh
Rajdeep Singh - avatar
+ 1
I added some variables and made some changes in the for loops. Also added a new line after the first section. Just compare both codes and you can find the changes.
24th Nov 2021, 12:22 PM
Arun Ruban SJ
Arun Ruban SJ - avatar