子任务下载
我写的代码:
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
cin >> a >> b;
int base = 2 * a - 1;
int area = (base * a) / 2;
if (area > b) {
cout << "NO" << endl;
} else {
int total = a;
for (int i = 0; i < total; i++) {
for (int j = 0; j < total - i - 1; j++) {
cout << '.';
}
for (int k = 0; k < 2 * i + 1; k++) {
cout << '*';
}
for (int l = 0; l < total - i - 1; l++) {
cout << '.';
}
cout << endl;
}
}
return 0;
}
万分感谢