Output diamond in C (13 rows)

Source: Internet
Author: User

#include <stdio.h>

int main ()

{

int i,j;

First 7 lines in front of the tube

for (i=1;i<=7;i++)The case of a row represented within a//for loop

{

for (j=1;j<=7-i;j++)//controls the number of spaces in each line so that the spaces preceding each line are controlled in 7-i

printf ("");

For (j=1;j<= (2*i-1); j + +)//The number of "*" control outputs in front of each line is 2*i-1

printf ("*");

printf ("\ n");

}

6 lines after re-tube

for (i=1;i<=6;i++)

{

for (j=1;j<=i;j++)//control the number of spaces per line

printf ("");

For (j=1;j<=13-(2*i); j + +)//control the number of "*" per line

printf ("*");

printf ("\ n");

}

return 0;

}


This article is from the "Sunflower in the Sun" blog, please be sure to keep this source http://10796797.blog.51cto.com/10786797/1706936

Output diamond in C (13 rows)

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.