输入4
打印:* *
*
* *
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "input n: ";
cin >> n;
for(int i = 1; i < n; i++)
{
for(int j = 1; j < n; j++)
{
if(j == i || j == n-i)
cout << "*";
else
cout << " ";
if(j >= i && j >= n-i)
{
cout << endl;
break;
}
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载