- 【例38.2】 图形输出
题解
- 2025-7-20 22:34:00 @
#include <bits/stdc++.h>
using namespace std;
#define in cin
#define out cout
#define int long long
signed main() {
char ch;
int n;
in >> ch >> n;
if (ch == 'L') {
int cnt = n - 1;
for (int i = 1; i < n * 2; i++, cnt--) {
for (int j = 0; j < abs(cnt); j++)
out << ' ';
for (int j = 0; j < n - abs(cnt); j++)
out << '*';
for (int j = 1; j < n - abs(cnt); j++)
out << '*';
out << endl;
}
} else
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
out << '*';
out << endl;
}
return 0;
}
0 comments
No comments so far...
Information
- ID
- 144
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- # Submissions
- 56
- Accepted
- 3
- Uploaded By