some programs!

This commit is contained in:
rogerwang2008 committed 2026-09-25 20:20:01 +08:00
1 parent 5d30e847c1
commit ed054247d5
32 files changed
+1882 -149

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#include <iostream>
void print_filled_rectangle(int h, int w, char c) {
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
std::cout << c;
}
std::cout << std::endl;
}
}
void print_unfilled_rectangle(int h, int w, char c) {
for (int i = 0; i < w; i++) {
std::cout << c;
}
std::cout << std::endl;
for (int i = 0; i < h - 2; i++) {
std::cout << c;
for (int j = 0; j < w - 2; j++) {
std::cout << " ";
}
std::cout << c << std::endl;
}
for (int i = 0; i < w; i++) {
std::cout << c;
}
std::cout << std::endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int h, w;
char c;
bool filled;
while (std::cin >> h >> w >> c >> filled) {
if (filled) {
print_filled_rectangle(h, w, c);
} else {
print_unfilled_rectangle(h, w, c);
}
}
return 0;
}