Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <sstream>
- #include <iostream>
- #include <string>
- using namespace std;
- bool isLimit(char c) {
- char lim[] = { ' ', '\t', '\n' };
- for (int i = 0; i < sizeof(lim); ++i)
- if (c == lim[i]) return true;
- return false;
- }
- int main() {
- ifstream fin("infile.txt");
- if (!fin) { cout << "Ошибка открытия файла." << endl; return 1; }
- int count = 0;
- string word;
- ostringstream sentence;
- while (!fin.eof()) {
- char symb;
- while (isLimit(symb = fin.peek())) {
- sentence << symb;
- if (symb == '\n') break;
- fin.seekg(1, ios::cur);
- }
- fin >> word;
- sentence << word;
- char last = word[word.size() - 1];
- if ((last == '.') || (last == '!')) {
- sentence.str(""); // очистка потока
- continue;
- }
- if (last == '?') {
- cout << sentence.str();
- sentence.str("");
- count++;
- }
- }
- if (!count) cout << "Вопросительных предложений нет.";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement