From 7af168de0c561a770584c7a19e72dae382189786 Mon Sep 17 00:00:00 2001 From: Oleg Avilov Date: Sat, 29 Jan 2022 01:19:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- part1.h | 10 ---------- part2.cpp | 23 +++++++++++++++++++---- part2.h | 1 + 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/part1.h b/part1.h index 178e7da..a56b9f3 100644 --- a/part1.h +++ b/part1.h @@ -16,16 +16,6 @@ public: const char* what() const { return this->exception; } }; -void createDataStream(const std::string&); - -void createDataIterator(const std::string&); - -void ModifyContainerTransform(const std::string&, const std::string&); - -template < typename T > -void ModifyContainer(T&); //!!! Это к чему относится? - - void createDataStream(const std::string& filename_p) { diff --git a/part2.cpp b/part2.cpp index 38a0264..f124e35 100644 --- a/part2.cpp +++ b/part2.cpp @@ -37,12 +37,13 @@ void general::load_in() s = 0; - std::fstream in; //!!! Использовать надо ifstream или ofstream + std::ifstream in; //!!! Использовать надо ifstream или ofstream + // ~~~ исправил - in.open("accounts_data.bin", std::ios::binary | std::ios::in); + in.open("accounts_data.bin", std::ios::binary); if (!in.is_open()) return; account cur; @@ -245,17 +246,31 @@ void general::load_out_txt() //!!! По заданию в текстовый файл должна выводиться отформатированная таблица с шапкой. //!!! Шапка должна создаваться с использованием манипуляторой. + // ~~~ исправил + txt_out << std::setw(15) << + "Account number" << "|" << std::setw(15) << + "Account code" << "|" << std::setw(15) << + "Surname" << "|" << std::setw(15) << + "Money balance" << "|" << std::setw(25) << + "Account creation date" << "|" << std::setw(15) << + "Annual percentage" << std::endl << std::string(107, '-') << std::endl; while (iter != accounts_map.end()) { money_sum += iter->second.money; average_percentage += iter->second.annual_percentage; - txt_out << i++ << ")" << std::endl << iter->second << std::endl << std::endl; + txt_out << std::setw(15) << + iter->second.number << "|" << std::setw(15) << + iter->second.code << "|" << std::setw(15) << + iter->second.surname << "|" << std::setw(15) << + iter->second.money << "|" << std::setw(25) << + iter->second.creation_date << "|" << std::setw(15) << + iter->second.annual_percentage << "%" << std::endl; iter++; } - txt_out << "Total amount of accounts: " << accounts_map.size() << std::endl << + txt_out << std::endl << std::endl << "Total amount of accounts: " << accounts_map.size() << std::endl << "Money sum on all accounts: " << money_sum << std::endl << "Average annual percentage: " << round(average_percentage / accounts_map.size() * 100) / 100 << "%" << std::endl; txt_out.close(); diff --git a/part2.h b/part2.h index 48364d9..d00f54e 100644 --- a/part2.h +++ b/part2.h @@ -3,6 +3,7 @@ #include #include #include +#include -- GitLab