16 Print Graphics Problerm (I)

错误思想:1,想着分成三部分,左边空格,中间+,右边空格;

                   2,在输出空格上和输出+产生矛盾,

突破:看成两部分;

技能:只需要管输出空格剩下的就是+了,那么只需要决定输出多少空格和多少+就行了

           没必要右边也输出空格;

          

#include <stdio.h>
main()
{
    int i,j,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for (j=1;j<=n-i;j++)
            printf(" ");
        for (j=1;j<=2*i-1;j++)
          printf("+");
        printf("\n");
    }
}

 

转载于:https://www.cnblogs.com/zoti007/articles/9850998.html

相关文章:

  • 2021-04-08
  • 2021-10-12
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-07-12
猜你喜欢
  • 2021-08-28
  • 2021-08-08
  • 2022-01-16
  • 2022-01-14
  • 2021-05-15
  • 2021-06-18
  • 2021-09-20
相关资源
相似解决方案