Advertisement
SenyaSych

Untitled

Mar 15th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <conio.h>
  3. #include <iomanip>
  4. #include <iostream>
  5. #include <stdio.h>
  6. #include <time.h>
  7. #include <string>
  8. #include <windows.h>
  9. #include <clocale>
  10. #include <cmath>
  11. #include <fstream>
  12.  
  13. using namespace std;
  14.  
  15. bool pr(char s);
  16.  
  17. int main()
  18. {
  19.  
  20.    SetConsoleCP(1251);
  21.    SetConsoleOutputCP(1251);
  22.  
  23.     ifstream fin;
  24.     ofstream fout;
  25.     string s,p;
  26.     fin.open("in.txt");
  27.     getline(fin,s);
  28.     s = s + ",";
  29.     getline(fin,p);
  30.     fin.close();
  31.  
  32.  
  33.     fout.open("out.txt");
  34.  
  35.     fout<<"21.  Из заданной последовательности слов, разделенных запятыми, удалить слова, содержащие введенную с клавиатуры последовательность символов.\n\n";
  36.     fout<<"\nВаш текст:\n"<<s;
  37.  
  38.     string temp;
  39.     string otvet="";
  40.  
  41.     for(int i =0; i<s.size(); i++){
  42.         int pos = -1;
  43.         if ((s[i]==',')){
  44.             pos = temp.find(p);
  45.             if (pos < 0){
  46.                 otvet = otvet + temp;
  47.                 }
  48.                   temp = " ";
  49.         }
  50.         temp = temp + s[i];
  51.     }
  52.  
  53.     fout<<endl<<otvet<<endl;
  54.     fout<<endl<<endl<<endl;
  55.     system("pause");
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement