C/C++经典程序训练5---图形打印问题

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

相关文章:

  • 2022-12-23
  • 2021-04-07
  • 2021-05-22
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-10-08
  • 2021-06-04
  • 2022-12-23
  • 2021-09-24
相关资源
相似解决方案