From 83780c0d265267c20bb76cd7d78c243bebf15845 Mon Sep 17 00:00:00 2001 From: MartynovArV Date: Thu, 2 Oct 2025 11:58:50 +0300 Subject: [PATCH] first commit --- main.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ed01cf0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +int main() { + int interval; + cout << "Введите размер интервала (4-9): "; + cin >> interval; + + if (interval < 4 || interval > 9) { + cout << "ERROR" << endl; + return 1; + } + + // Ширина шкалы = 3 * interval + int width = 3 * interval; + + // Линия шкалы + for (int pos = 0; pos <= width; pos++) { + if (pos % interval == 0) { + cout << "|"; + } else { + cout << "-"; + } + } + cout << endl; + + // Числовые отметки + cout << "0"; + for (int spaces = 0; spaces < interval - 1; spaces++) { + cout << " "; + } + cout << interval; + + int remaining = width - interval; + string last_num = to_string(width); + for (int spaces = 0; spaces < remaining - last_num.length(); spaces++) { + cout << " "; + } + cout << width << endl; + + return 0; +} \ No newline at end of file