C/C++

Разработайте программу, которая выводит на экран таблицу:

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
using ut = unsigned char;
struct pg {
static void vl() {
system("chcp 866 > nul");
cout << ' ' << ut(0xB3) << ' ';
system("chcp 1251 > nul");
}
static void tl() {
system("chcp 866 > nul");
cout << ' ' << ut(0xC3) << string(6, ut(0xC4))
<< ut(0xC2) << string(22, ut(0xC4))
<< ut(0xC2) << string(21, ut(0xC4))
<< ut(0xC2) << string(23, ut(0xC4)) << ut(0xB4) << '\n';
system("chcp 1251 > nul");
}
static void ml() {
system("chcp 866 > nul");
cout << ' ' << ut(0xC3) << string(6, ut(0xC4))
<< ut(0xC5) << string(22, ut(0xC4))
<< ut(0xC5) << string(21, ut(0xC4))
<< ut(0xC5) << string(23, ut(0xC4)) << ut(0xB4) << '\n';
system("chcp 1251 > nul");
}
static void bl() {
system("chcp 866 > nul");
cout << ' ' << ut(0xC3) << string(6, ut(0xC4))
<< ut(0xC1) << string(22, ut(0xC4))
<< ut(0xC1) << string(21, ut(0xC4))
<< ut(0xC1) << string(23, ut(0xC4)) << ut(0xB4) << '\n';
system("chcp 1251 > nul");
}
static void top() {
system("chcp 866 > nul");
cout << ' ' << ut(0xDA) << string(75, ut(0xC4)) << ut(0xBF) << '\n';
system("chcp 1251 > nul");
}
static void bottom() {
system("chcp 866 > nul");
cout << ' ' << ut(0xC0) << string(75, ut(0xC4)) << ut(0xD9) << '\n';
system("chcp 1251 > nul");
}
static void line(const string& str) {
pg::vl();
cout << left << setw(73) << str;
pg::vl();
puts("");
}
};
struct Record {
string y;
string sd;
string ad;
string of;
Record() = default;
Record(string&& y, string&& sd, string&& ad, string&& of)
: y(y), sd(sd), ad(ad), of(of){}

friend ostream& operator<<(ostream& out, const Record& rec) {
const ut v = 0xB3;
out << left;
pg::vl();
out << setw(4) << rec.y;
pg::vl();
out << setw(20) << rec.sd;
pg::vl();
out << setw(19) << rec.ad;
pg::vl();
out << setw(21) << rec.of;
pg::vl();
return out;
}
};
int main() {
system("chcp 1251 > nul");
vector box{
Record("Год", "Научный руководитель", "Диаметр антенны (м)", "Рабочая частота (МГц)"),
Record("1960", "Дрейк", "26", "1420"),
Record("1970", "Троицкий", "14", "1875"),
Record("1978", "Хоровиц", "300", "1665")
};
pg::top();
pg::line("Проекты поиска внеземных сигналов");
pg::tl();
cout << box.front() << '\n';
for (auto i = 1U; i < box.size(); ++i) {
pg::ml();
cout << box.at(i) << '\n';
}
pg::bl();
pg::line("Примечание: наблюдались объекты от 2 звёзд до нескольких галактик");
pg::bottom();
system("pause > nul");
}
Михаил Беляев
Михаил Беляев
78 706
Лучший ответ

Похожие вопросы