Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream>
  3. #include <cmath>
  4. #include <clocale>
  5. #include <string>
  6. #include <fstream>
  7. using namespace std;
  8. int main (){
  9.     setlocale(0, "rus");  
  10.     int size,l;
  11.     char kon;
  12.     string str,str1;
  13.     bool flag = false;
  14.     ifstream op("g.DAT");
  15.     while(getline(op,str, '\n')){
  16.         int k = 0;
  17.         bool flag;
  18.         for(int i = 0; i < (str.length()+1); i++){
  19.             if(str[i] == ' ' || i == str.length()){
  20.                 for(int l = k; l < i; l++){
  21.                     cout << str[l] << " ";
  22.                     int count = 0;
  23.                     for (int d = 0; d < i/2; d++){
  24.                         if(str[d]==str[i-1-d]){
  25.                             count++;
  26.                         }
  27.                     }
  28.                     if(count == ((i-1)/2)) {
  29.                         flag = true;
  30.                     }
  31.                     else {
  32.                         flag = false;
  33.                     }
  34.                 }
  35.                 cout << endl;
  36.                 if (flag){
  37.                     cout << "Самое большое слово палиндром: ";
  38.                     for(int l = k; l < i; l++)
  39.                         cout << str[l];
  40.                     cout << endl;
  41.                 }
  42.                 k=i+1;
  43.                 flag = false;
  44.             }
  45.         }
  46.     }
  47. system("pause");
  48. return 0;      
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement