Advertisement
artemgf

Переводчик

Dec 24th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <set>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <stdio.h>
  8. #include <cmath>
  9. #include <math.h>
  10. #include <queue>
  11. #include <stack>
  12. #include <climits>
  13. #include <deque>
  14. #include <ctime>
  15.  
  16. using namespace std;
  17.  
  18. typedef long long ll;
  19. typedef unsigned long long ull;
  20. typedef unsigned int ui;
  21. string H[10];
  22. void write(string h)
  23. {
  24.     int u = h.size();
  25.     for (int i = 0; i < h.size(); i++)
  26.     {
  27.         if (i + 1 == h.size())
  28.             cout << "<" << H[h[i] - '0'] << ">@<" << H[u] << "oibt>";
  29.         else
  30.             cout << "<" << H[h[i] - '0'] << ">@<" << H[u] << "oibt> ";
  31.         u--;
  32.     }
  33. }
  34. int main()
  35. {
  36.     for (int i = 0; i <= 9; i++)
  37.     {
  38.         cin >> H[i];
  39.     }
  40.     string s;
  41.     getline(cin, s);
  42.     getline(cin, s);
  43.     char last = ' ';
  44.     ll start = -1;
  45.     for (int i = 0; i < s.size(); i++)
  46.     {
  47.         if (s[i] >= '0'&&s[i] <= '9')
  48.         {
  49.             if (last < '0' || last>'9')
  50.                 start = i;
  51.         }
  52.         else
  53.             if (start != 0)
  54.             {
  55.                 if (last >= '0'&&last <= '9' && (s[i]<'a' || s[i]>'z') && (s[i]<'A' || s[i]>'Z') && (s[start - 1]<'a' || s[start - 1]>'z') && (s[start - 1]<'A' || s[start - 1]>'Z'))
  56.                 {
  57.                     string dig = s.substr(start, i - start);
  58.                     if (dig.size() <= 9)
  59.                     {
  60.                         write(dig);
  61.                         cout << s[i];
  62.                     }
  63.                     else
  64.                         cout << dig << s[i];
  65.                 }
  66.                 else
  67.                     if (last >= '0'&&last <= '9')
  68.                     {
  69.                         string dig = s.substr(start, i - start);
  70.                         cout << dig << s[i];
  71.                     }
  72.                     else
  73.                         cout << s[i];
  74.             }
  75.             else
  76.             {
  77.                 if (last >= '0'&&last <= '9' && (s[i]<'a' || s[i]>'z') && (s[i]<'A' || s[i]>'Z'))
  78.                 {
  79.                     string dig = s.substr(start, i - start);
  80.                     if (dig.size() <= 9)
  81.                     {
  82.                         write(dig);
  83.                         cout << s[i];
  84.                     }
  85.                     else
  86.                         cout << dig << s[i];
  87.                 }
  88.                 else
  89.                     if (last >= '0'&&last <= '9')
  90.                     {
  91.                         string dig = s.substr(start, i - start);
  92.                         cout << dig << s[i];
  93.                     }
  94.                     else
  95.                         cout << s[i];
  96.             }
  97.         last = s[i];
  98.     }
  99.  
  100.     if (start != 0)
  101.     {
  102.         if ((last >= '0'&&last <= '9') && (s[start - 1]<'a' || s[start - 1]>'z') && (s[start - 1]<'A' || s[start - 1]>'Z'))
  103.         {
  104.             string dig = s.substr(start, s.size() - start);
  105.             if (dig.size() <= 9)
  106.             {
  107.                 write(dig);
  108.             }
  109.             else
  110.                 cout << dig;
  111.         }
  112.         else
  113.             if (last >= '0'&&last <= '9')
  114.             {
  115.                 string dig = s.substr(start, s.size() - start);
  116.                 cout << dig;
  117.             }
  118.     }
  119.     else
  120.         if (last >= '0'&&last <= '9')
  121.         {
  122.             string dig = s.substr(start, s.size() - start);
  123.             if (dig.size() <= 9)
  124.             {
  125.                 write(dig);
  126.             }
  127.             else
  128.                 cout << dig;
  129.         }
  130.         else
  131.             if (last >= '0'&&last <= '9')
  132.             {
  133.                 string dig = s.substr(start, s.size() - start);
  134.                 cout << dig;
  135.             }
  136.     system("pause");
  137.     return 0;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement