Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- ofstream fout;
- string path;
- cout << "Enter file name" << endl;
- cin >> path;
- fout.open(path, ofstream::app);
- //// обработка файла
- vector<string> lines;
- fout.close();
- ifstream fin;
- fin.open(path, ifstream::app);
- int N, M;
- fin >> N >> M;
- int filelen = 0;
- string trash;
- getline(fin, trash);
- while (filelen < N)
- {
- string line = " ";
- getline(fin, line);
- lines.push_back(line);
- filelen++;
- };
- // сортировка
- vector<string> newlines;
- for (int k = 0; k < N; k++) {
- for (int i = 0; i < N; i++)
- {
- if (i == N - 1)
- {
- break;
- } //сортировка по алфавиту ( плохая:) )
- if (lines[i] > lines[i + 1])
- {
- string a;
- a = lines[i];
- lines[i] = lines[i + 1];
- lines[i + 1] = a;
- }
- }
- }
- for (int i = 0; i < lines.size(); i++)
- {
- string dots = ".";
- if (lines[i].size() < M)
- {
- int amount_dots = M - lines[i].size(); //дополнение точками
- for (int i = 0; i < amount_dots-1; i++)
- {
- dots += ".";
- }
- lines[i] = lines[i] + dots;
- }
- }
- for (auto x : lines)
- {
- cout << x << endl;
- }
- fout.open("B.txt");
- for (auto x : lines)
- {
- fout << x << endl;
- }
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement