Description |
n(n<100)组测试数据。每组测试数据输入一个整数m(1<m<100)表示三角旗的行数。打印出m行如图的三角旗形状。 |
Input |
第一行输入整数n,表示n组测试数据。 以下每行输入m,表示打印m行三角旗。 |
Output |
按格式输出由*组成的三角旗。 |
Sample Input |
2 3 5 |
Sample Output |
* *** ***** * *** ***** ******* ********* |
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main() {
int n;
int a;
cin >> a;
while (a--) {
cin >> n;
for (int i = 1;i<=n;i++) {
for (int j = 0;j < n - i;j++) {
cout << ' ';
}
for (int j = 0;j < 2*i-1;j++) {
cout << "*";
}
cout << endl;
}
}
return 0;
}