To love with C Language.

Source: Internet
Author: User

National Day Our laboratory has set up homework, one of which is to use the Process Control statements to print the shape

*

***

*****

*******

*****

***

*

The code is as follows

  #include <stdio.h>
 int main ()
 {
     int a,b,c;
     for (a=0;a<=3;a++)
     {for (b=0;b<=3-a;b++)
      printf ("");
          for (c=0;c<=2*a;c++)
     printf ("*");
     printf ("\ n");
    }
     for (a=0;a<=3;a++)
     {
          for (b=0;b<=a+1;b++)
             printf ("");
         for (c=0;c<=4-2*a;c++)
             printf ("*");
         printf ("\ n");
    }

After finishing this assignment, I had the whim to make this kind of graphic, so that I could make a love pattern with a similar process control Statement. (programmer's Romance)

So I imagined a picture like This.

*   *

*** ***

*********

*******

*****

***

*

PS1 (here because the typography is not very GOOD)

PS2 (because It is a beginner, so you can only do this simple pattern)

In the first half I couldn't figure out what algorithm to use, so I used only the most rudimentary printf to print (hopefully a great God can teach me how to do it)

In the second half I refer to our work and use the Process Control statements to complete

The final code is like This.

#include <stdio.h>
int main ()
{
int a,b,c;
printf ("* * \ n");
printf ("* * * * \ n");
For (a=0;a<=8;a++)
{
For (b=1;b<=a;b++)
printf ("");
For (c=0;c<=8-2*a;c++)
printf ("*");
printf ("\ n");
}
Return 0;
}

I think that in addition to printing with printf only, This is the most humble way of painting love, the search on the internet is using coordinates and so on, which I have not learned at Present.

Although the code is very primitive, but still can not help to share with you, if there is a more fool-like and more beautiful or efficient way, I hope to have the great god Guidance.

To love with C Language.

Related Article

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.