Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3. #include<vector>
  4. #include <queue>
  5. #include <stack>
  6. #include <string>
  7. #include <algorithm>
  8. #include <climits>
  9. #include<regex>
  10. using namespace std;
  11.  
  12.  
  13. int main()
  14. {
  15. freopen("input.txt", "r", stdin);
  16. freopen("output.txt", "w", stdout);
  17.  
  18. string s, ss, a = "[a-zA-Z]\\w*", d = "\\d";
  19. int longe = 1;
  20. int maxx = -1, max_i = -1, max_j = -1;
  21. smatch result;
  22. regex smatch1
  23. {
  24. "[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])* *= *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*|[a-zA-Z]\\w*\\( *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*( *[-+*/] *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*))*|,| )* *\\))( *[-+*/] *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*|[a-zA-Z]\\w*\\( *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*( *[-+*/] *(\\d+|[a-zA-Z]\\w*(\\[( *([a-zA-Z]\\w*|\\d+)( *[-+*/] *(\\d+|[a-zA-Z]\\w*))* *)\\])*))*|,| )* *\\)))* *;"
  25. };
  26. int counter = 0;
  27. while (getline(cin, s))
  28. {
  29. counter++;
  30. while (regex_search(s, result, smatch1))
  31. {
  32. cout << counter << ' ';
  33. cout << result.position() + longe << ' ';
  34. if (longe > 1)
  35. cout << result.position() + result[0].length() + longe - 1 << ' ';
  36. else
  37. cout << result.position() + result[0].length();
  38. s = s.substr(result.position() + result[0].length(), s.length() - result.position() - 1);
  39. longe += result.position() + result[0].length();
  40. cout << endl;
  41. }
  42. longe = 1;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement