Advertisement
LegoSosiska

Untitled

Nov 19th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include <algorithm>
  5. #include <fstream>
  6. #include <string>
  7.  
  8. int main() {
  9.     std::fstream str;
  10.     std::ofstream ltr;
  11.     str.open("f.txt");
  12.     ltr.open("g.txt");
  13.     if (!str.is_open()) {
  14.         std::cout << "FAILED TO OPEN FILE 1";
  15.     }
  16.     if (!ltr.is_open()) {
  17.         std::cout << "FAILED TO OPEN FILE 2";
  18.     }
  19.     int max = 0;
  20.     std::vector<std::string> a(1000);
  21.     std::vector<std::pair<int, std::pair<int, int>>> mir(1000);
  22.     int i = 0;
  23.     for (;; ++i) {
  24.         std::getline(str, a[i]);
  25.         if (a[i] == "EOF") {
  26.             break;
  27.         }
  28.         for (int j = 0; a[i][j] == ' ';) {
  29.             a[i] = a[i].substr(1, a[i].size() - 1);
  30.         }
  31.         bool f = false;
  32.         int c = 0, p = 0, l = 0;
  33.         for (int j1 = 0; a[i][j1] != '\n'; ++j1) {
  34.             if (a[i][j1] != ' ') {
  35.                 ++c;
  36.                 f = false;
  37.             }
  38.             else {
  39.                 if (!f) {
  40.                     ++l;
  41.                 }
  42.                 f = true;
  43.             }
  44.             ++p;
  45.         }
  46.         if (f) {
  47.             l -= 1;
  48.         }
  49.         mir[i].first = c;
  50.         mir[i].second.first = p;
  51.         mir[i].second.second = l;
  52.         if (p > max) {
  53.             max = p;
  54.         }
  55.     }
  56.     for (int q = 0; q < i; ++q) {
  57.         int spaces = 0;
  58.         for (int w = 0; w < mir[q].second.first - 1; ++w) {
  59.             if (a[q][w] != ' ') {
  60.                 ltr << a[q][w];
  61.             }
  62.             else {
  63.                 ++spaces;
  64.                 if (spaces > (mir[q].first - mir[i].second.first) / mir[i]
  65.             }
  66.         }
  67.     }
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement