Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 25 Oct 2012 22:23:04 -0500 Message-ID: <508A021C.387C@mindspring.com> Date: Thu, 25 Oct 2012 23:23:08 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: Write a program to print star using * ? References: <9291e324-bdc8-4153-b40e-4c53fc4bcec3@googlegroups.com> <5086F3C1.2FED@mindspring.com> <1btxtky76l.fsf@new-snowball.wb.pfeifferfamily.net> <508791B0.4173@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 156 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.217.20 X-Trace: sv3-1uM4tTYTPbB0TUsaDpgBr6Ymu25x0EeiIvRS3MMw0w4tJXS7IflCKV+BD7Ekz5l1jlY7f55kCXPYWu4!oRzsAIGWhPdiyUrAMcC4JiXO/BAGnn+mIm00U8prKVcoTYu8fDsekJFqzqPqJuSFU8IjFiHbbGEj!b9IwpV4j5Q== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 5631 Xref: csiph.com comp.lang.c:27708 pete wrote: > > Joe Pfeiffer wrote: > > > > pete writes: > > > > > Nikhil Joshi wrote: > > >> > > >> On Tuesday, October 23, 2012 9:22:33 PM UTC+5:30, Nikhil Joshi wrote: > > >> > guys help me in making thi program? > > >> > > >> main() > > >> { > > >> int i,j; > > >> for(i=0;i<5;i++) > > >> { > > >> for(j=i;j<5;j++) > > >> { > > >> printf("*"); > > >> printf("\n"); > > >> } > > >> } > > >> getch(); > > >> } > > >> > > >> this is basic structure printing star.. > > >> but dont know how make a program for star? > > > > > > /* BEGIN new.c */ > > > Hey -- don't just do his homework for him! > > /* BEGIN star.c output */ And now, because it's almost the same program, something that resembles a Koch snowflake: /* BEGIN snowflake.c output */ ***** ****** ** ****** *** ***************** ***************** ** *** ** *** *** ****** ******* ***** ***** ***** ***** ***** ***** ****** ****** ******* ****** ** ****** *** ** *** ** *** *** *** ** *** ** ************************************************* ************************************************* ** *** ** *** ****** ****** *** *** ****** *** ** ****** ******* ****** ******* ****** ***** ***** ****** ***** ***** ***** ***** ** ***** ***** ****** ******* ******* ****** ** *** ** *** *** *** *** * *** ** ***************** ***************** ***************** ***************** *** ****** *** *** ** *** *** ****** ****** ****** ****** ***** ***** ****** ****** ** ****** *** *** ** *** ** ***************** ***************** ***************** ***************** ** *** ** *** *** *** ****** *** ** ****** ******* ******* ****** ***** ***** ***** ***** ***** ***** ** ***** ***** ****** ******* ****** ******* ****** ** *** ** *** *** ****** *** *** * *** ** ******************** ****** *** ***************** ************************************************* *** ****** *** ***************** *** ** *** *** ****** ****** ** ******* ****** ****** ****** ******* ****** ** *** *** ** ****** ******* ****** ******* ** *** ** *** *** ***************** **************** * ****** * ****** **** /* END snowflake.c output */ /* BEGIN snowflake.c */ #include /* ** Running time is O(D*D*D*D) */ #define D 50 #define NMEMB(A) (sizeof (A) / sizeof *(A)) int main(void) { size_t i, x, y; unsigned ran; char array[D][D + 1]; char *const a = *array; long unsigned seed = 123456789LU; const struct { size_t x; size_t y; } point[] = { { 0, D / 2 - 1}, {D * 3 / 4 - 1, 0}, {D * 3 / 4 - 1, D - 1}, { D / 4, 0}, { D / 4, D - 1}, { D - 1, D / 2 - 1} }; for (i = 0; i != sizeof array; ++i) { a[i] = ' '; } for (i = 0; i != sizeof array; a[i - 1] = '\n') { i += sizeof *array; } x = point[1].x; y = point[1].y; for (i = 0; i != sizeof array * sizeof array; ++i) { seed = seed * 69069LU + 362437LU & 0XFFFFFFFFLU; ran = (unsigned) (seed / 65536) % 32768; x = (point[ran % NMEMB(point)].x * 2 + x) / 3; y = (point[ran % NMEMB(point)].y * 2 + y) / 3; array[x][y] = '*'; } puts("/* BEGIN snowflake.c output */\n"); for (i = 0; i != sizeof array; ++i) { putchar(a[i]); } puts("/* END snowflake.c output */"); return 0; } /* END snowflake.c */ -- pete