C language-For Loop

Source: Internet
Author: User

 # Include  <  Stdio. h  >  
Void Print_triangle ( Int N, Int X, Int T)
// N is the number of rows for each small triangle, X is the number of consecutive output triangles, and T is the right displacement of the triangle (1 indicates 1 space)
{
Int I, K, J;
For (I = 0 ; I < N; I ++ ) // Number of control lines
{
For (K = 0 ; K < T; k ++ ) // Control displacement
Printf ( " % C " , 32 ); // The space ASCII code is 32.
For (J = X; j > 0 ; J -- ) // Number of controls
{
For (K = N - 1 ; K > I; k -- )
Printf ( " % C " , 32 );
For (K = 0 ; K < I * 2 + 1 ; K ++ )
Printf ( " % C " , 42 );
For (K = N; k > I && J > 1 ; K -- )
Printf ( " % C " , 32 );
}
Printf ( " \ N " );
}
}
Int Main ()
{
Int I, k, n, T;
Printf ( " Please input N: " );
Scanf ( " % D " , & N );

For (I = 1 ; I <= N; I ++ ) // Control the number of large triangle rows
{
T = N * (N - I );
Print_triangle (n, I, T );
}

Return 0 ;
}

Understanding this column should be fine for the for loop.

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.