Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26499

Re: PRINTING DIAMOND SHAPE WITH LOOPS!

Newsgroups comp.lang.java.programmer
Date 2013-11-12 05:21 -0800
References <bd7dee67.0408241759.3884e4e9@posting.google.com> <4wTWc.18629$cx.18110@bignews4.bellsouth.net> <llWWc.228978$eM2.215971@attbi_s51> <ecaee893-0ad6-48a6-b345-24a33436b4df@googlegroups.com> <mgl879dhdkql5i04bdaisghtkua8hvmq54@4ax.com>
Message-ID <c8f279f7-226f-42b6-8483-e9ce613ba353@googlegroups.com> (permalink)
Subject Re: PRINTING DIAMOND SHAPE WITH LOOPS!
From pchristor@yahoo.co.uk

Show all headers | View raw


On Saturday, 2 November 2013 01:32:28 UTC, Roedy Green  wrote:
> On Fri, 1 Nov 2013 01:30:23 -0700 (PDT), jyothi.m1089@gmail.com wrote,
> 
> quoted or indirectly quoted someone who said :
> 
> 
> 
> >can you please explain the logic of this program....
> 
> 
> 
> run your program in an IDE with the trace option.  You can see it
> 
> working.
> 
> -- 
> 
> Roedy Green Canadian Mind Products http://mindprod.com
> 
> Unlike many machines, computers require no water once they are
> 
> manufactured.

Here is another option:

public static void main(String[] args) {
		
		int x=9;
		int m=x/2;
		StringBuilder str1= new StringBuilder(x);
		for(int i=0; i<m; i++){str1.append(" ");}
		str1.append("*");
		System.out.println(str1.toString());
		for(int j=1; j<x; j++){
			if(j<=m){	str1.deleteCharAt(m-j);
						str1.append("**");
			}else{
				str1.delete(m,m+2 ); str1.insert(0, " ");
			}
		System.out.println(str1.toString());
		}
	}

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: PRINTING DIAMOND SHAPE WITH LOOPS! jyothi.m1089@gmail.com - 2013-11-01 01:30 -0700
  Re: PRINTING DIAMOND SHAPE WITH LOOPS! rossum <rossum48@coldmail.com> - 2013-11-01 13:03 +0000
  Re: PRINTING DIAMOND SHAPE WITH LOOPS! Mike Amling <mamling@chaff.us> - 2013-11-01 09:59 -0500
  Re: PRINTING DIAMOND SHAPE WITH LOOPS! Roedy Green <see_website@mindprod.com.invalid> - 2013-11-01 18:32 -0700
    Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-12 05:21 -0800
      Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-11-27 15:57 -0800
        Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-27 19:21 -0500
        Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-28 17:45 -0800
          Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-28 21:10 -0500
            Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 03:03 -0800
              Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-29 12:33 +0100
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 09:01 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 13:15 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:06 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:24 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 20:59 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-30 06:57 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-30 10:31 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-12-02 15:32 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-12-04 03:45 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-12-09 21:10 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-12-05 00:15 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-12-09 21:14 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-29 19:58 +0100
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! pchristor@yahoo.co.uk - 2013-11-29 17:12 -0800
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Joerg Meier <joergmmeier@arcor.de> - 2013-11-30 02:55 +0100
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 21:01 -0500
                Re: PRINTING DIAMOND SHAPE WITH LOOPS! Lew <lewbloch@gmail.com> - 2013-12-02 15:31 -0800
              Re: PRINTING DIAMOND SHAPE WITH LOOPS! Arne Vajhøj <arne@vajhoej.dk> - 2013-11-29 12:48 -0500

csiph-web