C + + star graphic--hollow triangle (star centered) (Core code introduction)

Source: Internet
Author: User

//output Another triangle of asterisks (the asterisk is aligned in the center)    intA//controls the number of rows that make up the asterisk of the trianglecout<<"Please enter the number of rows N (n>=2) of the asterisk to form the three-solution: \ N"; CIN>>A;  for(intI=1; i<a+1; i++)//control number of rows    {         for(intj=a-i;j>=0; j--) {cout<<"  ";//Here are two spaces        }         for(intk=0;k<2*i-1; k++)//control the number of each planetary number.         {            if(i==0|| i==a) {cout<<"* ";//a space is added to the asterisk (to make it more intuitive to print out a graphic).             }            Else            if(k==0|| k==2*i-2) {cout<<"* "; }                            Elsecout<<"  "; } cout<<Endl; }

C + + star graphic--hollow triangle (star centered) (Core code introduction)

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.