Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<math.h>
- #include<vector>
- #include <queue>
- #include <stack>
- #include <string>
- #include <algorithm>
- #include <climits>
- #include<regex>
- using namespace std;
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- string s, ss, a = "[a-zA-Z]\\w*", d = "\\d";
- int longe = 1;
- int maxx = -1, max_i = -1, max_j = -1;
- smatch result;
- regex smatch1
- {
- "[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*))* *)\\])*))*|,| )* *\\)))* *;"
- };
- int counter = 0;
- while (getline(cin, s))
- {
- counter++;
- while (regex_search(s, result, smatch1))
- {
- cout << counter << ' ';
- cout << result.position() + longe << ' ';
- if (longe > 1)
- cout << result.position() + result[0].length() + longe - 1 << ' ';
- else
- cout << result.position() + result[0].length();
- s = s.substr(result.position() + result[0].length(), s.length() - result.position() - 1);
- longe += result.position() + result[0].length();
- cout << endl;
- }
- longe = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement