Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.38 KB | None | 0 0
  1. #pragma hdrstop
  2. #pragma argsused
  3.  
  4. #ifdef _WIN32
  5. #include <tchar.h>
  6. #else
  7.   typedef char _TCHAR;
  8.   #define _tmain main
  9. #endif
  10.  
  11. #include <stdio.h>
  12. #include <iostream>
  13. #include <windows.h>
  14. #include <conio.h>
  15. using namespace std;
  16.  
  17.  
  18.  
  19. //Too swift for Theex, too quick for Gallow
  20.  
  21. void Answer(char* b, int count)
  22. {
  23.     for (int t=0; t < count; t++)
  24.         cout << b[t] ;
  25. }
  26.  
  27. void Letters(char* str)
  28. {
  29.     int count=0;
  30.     char b[1000];
  31.     for (int i = 0; str[i]; i++)
  32.     {
  33.         if ((str[i]=='c')&&((str[i+1]=='e')||(str[i+1]=='i')||(str[i+1]=='y')))
  34.         {
  35.             if((count != 0 && b[count-1] != 's' && b[count-1] != 'S') || count == 0)
  36.             {
  37.                 b[count] = 's';
  38.                 count++;
  39.             }
  40.         }
  41.         else if ((str[i]=='C')&&((str[i+1]=='e')||(str[i+1]=='i')||(str[i+1]=='y')))
  42.         {
  43.             if((count != 0 && b[count-1] != 'S' && b[count-1] != 's')   || count == 0)
  44.             {
  45.                 b[count] = 'S';
  46.                 count++;
  47.             }
  48.         }
  49.         else  if (str[i]=='c')
  50.         {
  51.             if((count != 0 && b[count-1] != 'k' && b[count-1] != 'K')   || count == 0)
  52.             {
  53.                 b[count] = 'k';
  54.                 count++;
  55.             }
  56.         }
  57.         else  if (str[i]=='C')
  58.         {
  59.             if((count != 0 && b[count-1] != 'K' && b[count-1] != 'k')   || count == 0)
  60.             {
  61.                 b[count] = 'K';
  62.                 count++;
  63.             }
  64.         }
  65.         else  if ((str[i]=='q')&&(str[i+1]=='u'))
  66.         {
  67.             if((count != 0 && b[count-1] != 'k' && b[count-1] != 'K')   || count == 0)
  68.             {
  69.                 b[count] = 'k';
  70.                 b[count + 1] = 'v';
  71.                 count += 2;
  72.             }
  73.         }
  74.         else  if ((str[i]=='Q')&&(str[i+1]=='u'))
  75.         {
  76.             if((count != 0 && b[count-1] != 'K' && b[count-1] != 'k')   || count == 0)
  77.             {
  78.                 b[count] = 'K';
  79.                 b[count + 1] = 'v';
  80.                 count += 2;
  81.             }
  82.         }
  83.         else  if (str[i]=='q')
  84.         {
  85.             if((count != 0 && b[count-1] != 'k' && b[count-1] != 'K') || count == 0)
  86.             {
  87.                 b[count] = 'k';
  88.                 count++;
  89.             }
  90.         }
  91.         else  if (str[i]=='Q')
  92.         {
  93.             if((count != 0 && b[count-1] != 'K' && b[count-1] != 'k')  || count == 0)
  94.             {
  95.                 b[count] = 'K';
  96.                 count++;
  97.             }
  98.         }
  99.  
  100.         else  if (str[i]=='x')
  101.         {
  102.             if((count != 0 && b[count-1] != 'k' && b[count-1] != 'K')   || count == 0)
  103.             {
  104.                 b[count] = 'k';
  105.                 b[count + 1] = 's';
  106.                 count += 2;
  107.             }
  108.             else if(count != 0 && b[count-1] == 'k' && b[count-1] != 'K')
  109.             {
  110.                 b[count] = 's';
  111.                 count++;
  112.             }
  113.         }
  114.         else  if (str[i]=='X')
  115.         {
  116.             if((count != 0 && b[count-1] != 'K' && b[count-1] != 'k')   || count == 0)
  117.             {
  118.                 b[count] = 'K';
  119.                 b[count + 1] = 's';
  120.                 count += 2;
  121.             }
  122.             else if(count != 0 && b[count-1] == 'K' && b[count-1] != 'k')
  123.             {
  124.                 b[count] = 's';
  125.                 count++;
  126.             }
  127.         }
  128.         else  if (str[i]=='w')
  129.         {
  130.             if((count != 0 && b[count-1] != 'v' && b[count-1] != 'V') || count == 0)
  131.             {
  132.                 b[count] = 'v';
  133.                 count++;
  134.             }
  135.         }
  136.         else  if (str[i]=='W')
  137.         {
  138.             if((count != 0 && b[count-1] != 'V' && b[count-1] != 'v')  || count == 0)
  139.             {
  140.                 b[count] = 'V';
  141.                 count++;
  142.             }
  143.         }
  144.         else  if ((str[i]=='p')&&(str[i+1]=='h'))
  145.         {
  146.             if((count != 0 && b[count-1] != 'f' && b[count-1] != 'F')   || count == 0)
  147.             {
  148.                 b[count] = 'f';
  149.                 count++;
  150.             }
  151.             i++;
  152.         }
  153.         else  if ((str[i]=='P')&&(str[i+1]=='h'))
  154.         {
  155.             if((count != 0 && b[count-1] != 'F' && b[count-1] != 'f') || count == 0)
  156.             {
  157.                 b[count] = 'F';
  158.                 count++;
  159.             }
  160.             i++;
  161.         }
  162.         else  if ((str[i]=='y')&&(str[i+1]=='o')&&(str[i+2]=='u'))
  163.         {
  164.             if((count != 0 && b[count-1] != 'u' && b[count-1] != 'U')  || count == 0)
  165.             {
  166.                 b[count] = 'u';
  167.                 count++;
  168.             }
  169.             i += 2;
  170.         }
  171.         else  if ((str[i]=='o')&&(str[i+1]=='o'))
  172.         {
  173.             if((count != 0 && b[count-1] != 'u' && b[count-1] != 'U')  || count == 0)
  174.             {
  175.                 b[count] = 'u';
  176.                 count++;
  177.             }
  178.             i++;
  179.         }
  180.         else  if ((str[i]=='Y')&&(str[i+1]=='o')&&(str[i+2]=='u'))
  181.         {
  182.             if((count != 0 && b[count-1] != 'U' && b[count-1] != 'u')   || count == 0)
  183.             {
  184.                 b[count] = 'U';
  185.                 count++;
  186.             }
  187.             i += 2;
  188.         }
  189.         else  if ((str[i]=='O')&&(str[i+1]=='o'))
  190.         {
  191.             if((count != 0 && b[count-1] != 'U' && b[count-1] != 'u')   || count == 0)
  192.             {
  193.                 b[count] = 'U';
  194.                 count++;
  195.             }
  196.             i++;
  197.         }
  198.         else  if ((str[i]=='e')&&(str[i+1]=='e'))
  199.         {
  200.             if((count != 0 && b[count-1] != 'i' && b[count-1] != 'I')  || count == 0)
  201.             {
  202.                 b[count] = 'i';
  203.                 count++;
  204.             }
  205.             i++;
  206.         }
  207.         else  if ((str[i]=='E')&&(str[i+1]=='e'))
  208.         {
  209.             if((count != 0 && b[count-1] != 'I' && b[count-1] != 'i') || count == 0)
  210.             {
  211.                 b[count] = 'I';
  212.                 count++;
  213.             }
  214.             i++;
  215.         }
  216.         else  if ((str[i]=='t')&&(str[i+1]=='h'))
  217.         {
  218.             if((count != 0 && b[count-1] != 'z' && b[count-1] != 'Z')   || count == 0)
  219.             {
  220.                 b[count] = 'z';
  221.                 count++;
  222.             }
  223.             i++;
  224.         }
  225.         else  if ((str[i]=='T')&&(str[i+1]=='h'))
  226.         {
  227.             if((count != 0 && b[count-1] != 'Z' && b[count-1] != 'z')   || count == 0)
  228.             {
  229.                 b[count] = 'Z';
  230.                 count++;
  231.             }
  232.             i++;
  233.         }
  234.         else  if (str[i]==str[i+1])
  235.         {
  236.             if((count != 0 && b[count-1] != str[i])  || count == 0)
  237.             {
  238.                 b[count] = str[i];
  239.                 count++;
  240.             }
  241.             i++;
  242.  
  243.         }
  244. //            else  if ((str[i]=='C')||(str[i]=='Q')||(str[i]=='W')||(str[i]=='X'))
  245. //            {
  246. //         b[i]=str[i];
  247. //         count++;
  248. //       }
  249.         else
  250.         {
  251.             if((count != 0 && tolower(b[count-1]) != tolower(str[i]))   || count == 0)
  252.             {
  253.                 b[count] = str[i];
  254.                 count++;
  255.             }
  256.         }
  257.     }
  258.  
  259.     Answer(b, count);
  260. }
  261.  
  262. int _tmain(int argc, _TCHAR* argv[])
  263. {
  264.     SetConsoleCP(1251);
  265.     SetConsoleOutputCP(1251);
  266.     char str[81];
  267.  
  268.     cout << " Введите строку : ";
  269.     gets(str);
  270.     Letters(str);
  271.     getch();
  272.     return 0;
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement