站外题求调,悬5关
  • 板块灌水区
  • 楼主STEAM_ERROR
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/10/13 10:09
  • 上次更新2024/10/13 11:29:15
查看原帖
站外题求调,悬5关
1512776
STEAM_ERROR楼主2024/10/13 10:09

子任务下载


我写的代码:


#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;
}

万分感谢

2024/10/13 10:09
加载中...