Сommit
83780c0d26
@ -0,0 +1,42 @@
|
|||||||
|
#include <iostream>
|
||||||
|
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;
|
||||||
|
}
|
||||||
Загрузка…
Ссылка в новой задаче