- 【例38.2】 图形输出
题解
- 2025-3-24 17:28:53 @
#include <bits/stdc++.h> using namespace std;
int main () { char c; int n; cin >> c >> n; if (c == 'L') { for (int i = 1, sp = n - 1, st = 1; i <= n-1; i++, sp--, st += 2) { cout << setw(sp) << setfill(' ') << ' '; //printf("%c", sp, ' '); cout << setw(st) << setfill('') << ""; cout << "\n"; } cout << setw(2 * n - 1) << setfill('') << '' << "\n"; for (int i = n - 1, sp = 1; i >= 1; i--, sp++) { cout << setw(sp) << setfill(' ') << ' '; cout << setw(2 * i - 1) << setfill('') << ''; cout << "\n"; } } else { for (int i = 1; i <= n; i++) { cout << setw(n) << setfill('') << '*'; cout << "\n"; } } return 0; }
0 comments
Information
- ID
- 144
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- # Submissions
- 52
- Accepted
- 3
- Uploaded By