Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- vector<char> zn(3);
- zn = { '.', ',', '!', '?'};
- vector<string> m;
- string s;
- string username = " --- skazal ", fedya = " --- skazal Fedya.";
- fin >> s;
- fin >> s; username += s; string out = s; out += " signed off"; username += '.';
- getline(fin, s);
- string replik;
- fin >> s;
- while (getline(fin, s)) {
- replik = s.substr(1, s.size() - 1);
- bool k = true;
- for (int i = 0; i < 4; i++) {
- if (replik[replik.size() - 1] == zn[i]) {
- k = false;
- i = 5;
- }
- }
- if (k == true) {
- replik += ',';
- }
- if (replik[replik.size() - 1] == '.') {
- replik[replik.size() - 1] = ',';
- }
- m.push_back(replik);
- replik = "";
- fin >> s;
- }
- bool f = true;
- for (int i = 0; i < m.size() - 1; i++) {
- if (f == true) {
- fout << '"' << m[i] << '"' << fedya << endl;
- }
- else if (f == false) {
- fout << '"' << m[i] << '"' << username << endl;
- }
- f = !f;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment