+ 2
Please correct this so that the output is a heart
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();
+ 2
Ok thanks
+ 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..
+ 1
Actually I want to ask u what change u made
+ 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.