Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool ispal(int n, char s[1000][100])
  6. {
  7.     bool flag = false;
  8.     for (int i = 0; i < n; i++)
  9.     {
  10.         int d = strlen(s[i]);
  11.         if ((d == 1) || (d == 2))
  12.             flag = false;
  13.         for (int j = 0; j < (d / 2); j++)
  14.         {
  15.             if (s[i][j] != s[i][strlen(s[i]) - j - 1])
  16.             {
  17.                 flag = false;
  18.                 break;
  19.             }
  20.             flag = true;
  21.         }
  22.         if (flag == true) return true;
  23.     }
  24.     return false;
  25. }
  26.  
  27. bool is_letter(unsigned char c)
  28. {
  29.     if (c >= (unsigned char)'А' && c <= (unsigned char)'я')
  30.         return true;
  31.     else
  32.         return false;
  33. }
  34.  
  35. int main()
  36. {
  37.     setlocale(LC_ALL, "Russian");
  38.     FILE* input;
  39.     freopen_s(&input, "input.txt", "r", stdin);
  40.     unsigned char w[100], *pw = nullptr, *words[1000];
  41.     int c = 0, n = 0, i = 0;
  42.     while ((c = getchar()) >= 0)
  43.     {
  44.         if (is_letter(c))
  45.         {
  46.             pw = w;
  47.             i = 0;
  48.             while (is_letter(c))
  49.             {
  50.                 *pw++ = c;
  51.                 i++;
  52.                 c = getchar();
  53.             }
  54.         }
  55.         if (pw)
  56.         {
  57.             pw = nullptr;
  58.             words[n] = new unsigned char[i + 1];
  59.             for (int j = 0; j < i; j++)
  60.                 words[n][j] = w[j];
  61.             words[n++][i] = 0;
  62.         }
  63.     }
  64.  
  65.     for(int j=0; j<n; j++)
  66.     if (ispal(n, words) == true)
  67.     {
  68.         SortVowels(n, words);
  69.     }
  70.         //cout << words[j] << endl;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement