问题描述
编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
* * * * *
* * * *
* * *
* *
*
#include <iostream>
#include<algorithm>
#include <math.h>
using namespace std;
int main()
{
int n;
cin >> n;
if(n<=0)
return 0;
for(int i=n; i; i--) {
for (int j = 0; j < i; j++)
cout << "*" << " ";
cout << endl;
}
return 0;
}