zoukankan      html  css  js  c++  java
  • 我编写的一个显示菱形的C程序

     1#include <stdio.h>
     2
     3int main()
     4{
     5    int row;
     6    int counter, m, n;
     7    printf( "Enter the row of the diamond: " );
     8    scanf( "%d"&row );
     9
    10    //above the max line
    11    for ( counter = 1; counter <= ( row - 1 ) / 2; counter++ )
    12    {
    13        for ( m = 1; m < ( row + 1/ 2 - ( counter - 1 ); m++ )
    14            printf( " " );
    15        for ( n = 1; n <= 2 * counter - 1; n++ )
    16            printf( "*" );
    17        printf( "\n" );
    18    }

    19    
    20    //max line
    21    for ( n = 1; n <=  row; n++ )
    22            printf( "*" );
    23    printf ( "\n" );
    24
    25    //below the max line
    26    for ( counter = 1; counter <= ( row - 1 ) / 2; counter++ )
    27    {
    28        for ( m = 1; m <= counter; m++ )
    29            printf( " " );
    30        for ( n = 1; n <= row - ( m - 1 ) * 2; n++ )
    31            printf( "*" );
    32        printf( "\n" );
    33    }

    34    
    35    return 0;
    36}
  • 相关阅读:
    csp-s模拟 77/78 (达哥专场)
    csp-s 模拟76
    csp-s模拟75 导弹袭击
    反思集
    模拟69/70 考试反思
    抱大腿
    csp-s模拟61 甜圈
    实时记录
    好题思路集汇
    半集训反思 8.28 「路,还是要自己走的」
  • 原文地址:https://www.cnblogs.com/iPeterRex/p/1242590.html
Copyright © 2011-2022 走看看