Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <utility>
- #include <algorithm>
- #include <fstream>
- #include <string>
- int main() {
- std::fstream str;
- std::ofstream ltr;
- str.open("f.txt");
- ltr.open("g.txt");
- if (!str.is_open()) {
- std::cout << "FAILED TO OPEN FILE 1";
- }
- if (!ltr.is_open()) {
- std::cout << "FAILED TO OPEN FILE 2";
- }
- int max = 0;
- std::vector<std::string> a(1000);
- std::vector<std::pair<int, std::pair<int, int>>> mir(1000);
- int i = 0;
- for (;; ++i) {
- std::getline(str, a[i]);
- if (a[i] == "EOF") {
- break;
- }
- for (int j = 0; a[i][j] == ' ';) {
- a[i] = a[i].substr(1, a[i].size() - 1);
- }
- bool f = false;
- int c = 0, p = 0, l = 0;
- for (int j1 = 0; a[i][j1] != '\n'; ++j1) {
- if (a[i][j1] != ' ') {
- ++c;
- f = false;
- }
- else {
- if (!f) {
- ++l;
- }
- f = true;
- }
- ++p;
- }
- if (f) {
- l -= 1;
- }
- mir[i].first = c;
- mir[i].second.first = p;
- mir[i].second.second = l;
- if (p > max) {
- max = p;
- }
- }
- for (int q = 0; q < i; ++q) {
- int spaces = 0;
- for (int w = 0; w < mir[q].second.first - 1; ++w) {
- if (a[q][w] != ' ') {
- ltr << a[q][w];
- }
- else {
- ++spaces;
- if (spaces > (mir[q].first - mir[i].second.first) / mir[i]
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement