#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> char output[100][100] = {}; int main() { std::memset(output, '0', 100 * 100); for (int y = 0; y < 50; y++) { int from = y + 1; int to = std::min(100, 101 - y); for (int x = from; x < to; x++) { output[y][x] = '1'; } } for (int y = 50; y < 100; y++) { int from = 99 - y; int to = y; for (int x = from; x < to; x++) { output[y][x] = '1'; } } for (int y = 0; y < 100; y++) { fwrite(output[y], 1, 100, stdout); putchar('\n'); } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> char output[100][100] = {}; int main() { std::memset(output, '0', 100 * 100); for (int y = 0; y < 50; y++) { int from = y + 1; int to = std::min(100, 101 - y); for (int x = from; x < to; x++) { output[y][x] = '1'; } } for (int y = 50; y < 100; y++) { int from = 99 - y; int to = y; for (int x = from; x < to; x++) { output[y][x] = '1'; } } for (int y = 0; y < 100; y++) { fwrite(output[y], 1, 100, stdout); putchar('\n'); } return 0; } |