#include<iostream>
using namespace std;
void printchar(int n, char ch)
{
    for(int i = 0; i != n; ++i)
    cout << ch;
}
void fun(int i, int j, int n)
{

    printchar(i,’ ‘);
    printchar(j,’*’);
    cout << endl;
    if(j<n)
    {
        fun(i-1,j+2,n);    
        printchar(i,’ ‘);
        printchar(j,’*’);
        cout << endl;
    }
}
int main()
{
    cout << “input
number:”;
    int n;
    cin >> n;
    fun(n/2,1,n);
    return 0;
}

相关文章