Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Treu.h"
- using namespace std;
- int main() {
- Treu tr;
- tr.schet();
- tr.kol();
- tr.vivod();
- tr.reverse();
- cout << "\n";
- tr.vivod();
- }
- ==============================
- #ifndef Treu_h
- #define Treu_h
- class Treu {
- private:
- int n_n, * mas;
- public:
- Treu();
- void kol();
- void schet();
- void vivod();
- void reverse();
- ~Treu();
- };
- #endif
- ========================================
- #include "Treu.h"
- #include <iostream>
- #include <string>
- using namespace std;
- Treu::Treu() {
- cin >> n_n;
- if (n_n <= 10) {
- mas = new int[n_n];
- }
- else {
- exit(1);
- }
- }
- void Treu::kol() {
- cout << "N" << " " << "=" << " " << n_n << endl;
- }
- void Treu::schet() {
- for (int i = 0; i < n_n; i++) {
- cin >> mas[i];
- }
- }
- void Treu::vivod() {
- string res = "";
- for (int i = 0; i < n_n; i++) {
- string buf = "";
- buf = to_string(mas[i]);
- for (int j = 0; j < (5 - (int)buf.length()); j++) {
- res = res + " ";
- }
- res = res + buf;
- }
- cout << res;
- }
- void Treu::reverse()
- {
- for (int i = 0; i < n_n / 2; i++)
- {
- int t = mas[i];
- mas[i] = mas[n_n - i - 1];
- mas[n_n - i - 1] = t;
- }
- }
- Treu::~Treu() {
- delete[]mas;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement