Aleksandr_Grigoryev

АК 47

May 24th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <fstream>
  4. //3X1^2*X2^1*X3^7-2X1^1*X2^2*X3^3+S(2X1)-4C(2X1);X1^2-2X1^1+3X1^0;S(2X1)-4C(2X1)//
  5. using namespace std;
  6. int main()
  7. {
  8.     char x;
  9.     bool b = true;
  10.     int q = 1, n;
  11.     ifstream f("Text.txt");
  12.     while (f.peek() != EOF && b == true)
  13.     {
  14.         f >> x;
  15.         cout << x;
  16.         switch (q)
  17.         {
  18.         case 1:
  19.             if (x =='K')
  20.             {
  21.                 q = 2;
  22.             }
  23.             else if (x == 'D')
  24.             {
  25.                 q = 8;
  26.             }
  27.             else b = false;
  28.             break;
  29.         case 2:
  30.             if (x == ':')
  31.             {
  32.                 q = 3;
  33.             }
  34.             else b = false;
  35.             break;
  36.  
  37.         case 3:
  38.             if (x >= '(')
  39.             {
  40.                 q = 4;
  41.             }
  42.             else b = false;
  43.             break;
  44.  
  45.         case 4:
  46.             if (x == '~')
  47.             {
  48.                 q = 5;
  49.             }
  50.             else if (x >= 'A' && x <= 'Z')
  51.             {
  52.                 q = 6;
  53.             }
  54.             else b = false;
  55.             break;
  56.  
  57.  
  58.         case 5:
  59.             if (x >= 'A' && x <= 'Z')
  60.             {
  61.                 q = 6;
  62.             }
  63.             else b = false;
  64.             break;
  65.  
  66.  
  67.         case 6:
  68.             if (x == '/')
  69.             {
  70.                 q = 4;
  71.             }
  72.             else if (x == ')')
  73.             {
  74.                 q = 7;
  75.             }
  76.             else b = false;
  77.             break;
  78.  
  79.  
  80.         case 7:
  81.             if (x == '&')
  82.             {
  83.                 q = 3;
  84.             }
  85.             else if (x == ';')
  86.             {
  87.                 q = 1;
  88.             }
  89.             else b = false;
  90.             break;
  91.  
  92.  
  93.         case 8:
  94.             if (x == ':')
  95.             {
  96.                 q = 9;
  97.             }
  98.             else b = false;
  99.             break;
  100.  
  101.  
  102.         case 9:
  103.             if (x == '~')
  104.  
  105.             {
  106.                 q = 10;
  107.             }
  108.             else
  109.                 if (x>= 'A' && x<= 'Z')
  110.                 {
  111.                     q = 11;
  112.                 }
  113.             else b = false;
  114.             break;
  115.  
  116.  
  117.         case 10:
  118.             if (x >= 'A' && x <= 'Z')
  119.             {
  120.                 q = 11;
  121.             }
  122.             else b = false;
  123.             break;
  124.  
  125.  
  126.         case 11:
  127.             if (x == '&' || x == '/')
  128.             {
  129.                 q = 9;
  130.             }
  131.             else if (x == ';')
  132.             {
  133.                 q = 1;
  134.             }
  135.             else b = false;
  136.             break;
  137.         }
  138.     }
  139.     cout << endl;
  140.     if (b)
  141.         cout << "all right!!";
  142.     else
  143.         cout << "error";
  144.     cout << endl;
  145.     system("pause");
  146.     return 0;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment