zoukankan      html  css  js  c++  java
  • 输出以下图案:*****

    /*

    *****

     *****

      *****

       *****

        *****

    */

    #include <stdio.h>
    int main()
    {
        char a[5][9];
        int i,j;
        for(i=0;i<5;i++)
        for(j=0;j<=i+4;j++)
        {
            if(j<=i-1)
            a[i][j]=' ';//i=1 j=0 ' ' i=2 j=0,j=1 ' ' i=3 j=0 j=1 j=2 ' '
            else
            a[i][j]='*';
        }
        
        for(i=0;i<5;i++)
        {
            for(j=0;j<=i+4;j++)
            printf("%c",a[i][j]);
            printf(" ");
        }
        return 0;
     }

    ********************************************方法二********************************************************

    #include <stdio.h>
    int main()
    {
        char a[5]={'*','*','*','*','*'};
        int i,j,k;
        char space=' ';
        for(i=0;i<5;i++)
        {
        //    printf(" ");
        //    printf(" ");
            for(j=0;j<=i-1;j++)
            printf("%c",space);
            for(k=0;k<5;k++)
            printf("%c",a[k]);
            printf(" ");
        }

        return 0;
    }

  • 相关阅读:
    oracle lengthb
    layui-rp
    1709052基于框架新建 子项目
    echar 常用单词
    Leetcode 481.神奇字符串
    Leetcode 480.滑动窗口中位数
    Leetcode 479.最大回文数乘积
    Leetcode 477.汉明距离总和
    Leetcode 476.数字的补数
    Leetcode 475.供暖气
  • 原文地址:https://www.cnblogs.com/LiQingXin/p/13026354.html
Copyright © 2011-2022 走看看