#include <iostream> using namespace std; int flag=0; int n; int m; int space; int j; void print(int n) { m=1; for(int i=1;i<=n;i++) { j=1; space=(n-m)/2; while(j<=space) { cout<<" "; ++j; } while(j<=space+m) { cout<<"*"; ++j; } while(j<=n) { cout<<" "; ++j; } cout<<endl; if(i==(n+1)/2) { flag=1; } m= flag==0? m+2 : m-2; } } void main() { print(10); } 1.输入一个奇数n,输出对角线长为n的实心或者空心的菱形图案 如当n=5时,有: * *** ***** *** *