* Tower, Diamond

Source: Internet
Author: User

To output a case on the screen:
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*

EG1:

voidfun1 () {printf ("* \ n"); }voidfun2 () {printf ("* * \ n"); }voidFun3 () {printf ("* * * \"); }voidFun4 () {printf ("******* \ n"); }voidfun5 () {printf ("********* \ n"); }voidfun6 () {printf ("*********** \ n"); }voidfun7 () {printf ("*************\n"); }intMain () {fun1 ();    Fun2 ();    Fun3 ();    Fun4 ();    Fun5 ();    Fun6 ();    Fun7 ();    Fun6 ();    Fun5 ();    Fun4 ();    Fun3 ();    Fun2 ();    Fun1 (); return 0; } This way, I can think of the simplest and most of the action, is the full output ~ ~ ~

EG2:

intMain () {inti,j;  for(i=1;i<8; i++)  {       for(j=0;j<8-I.; j + +) printf (" ");  for(j=0;j<2*i-1 ; j + +) printf ("*"); printf ("\ n"); }    for(i=8;i>0; i--)  {       for(j=7-i;j>=0; j--) printf (" ");  for(j=2*i-2; j>=0; j--) printf ("*"); printf ("\ n"); }  return 0;}
This method looks comfortable, determines the number of rows, the main algorithm (or point of thinking) in the relationship between ' and ' * ' and the number of rows in the color of the relationship between the number of spaces and lines, the underscore is the relationship between * and the number of rows the second block of code is to write the relationship of the first block in reverse.

* Tower, Diamond

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.