-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompilers_and_parsers.cpp
More file actions
53 lines (44 loc) · 872 Bytes
/
Compilers_and_parsers.cpp
File metadata and controls
53 lines (44 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int t;
long int count=1,len=0,i,l;
cin>>t;
while(t--)
{
char str[1000001];
cin>>str;
count=1;
len=0;
if(str[0]=='>')
{
cout<<0<<"\n";
}
if(str[0]=='<')
{
l=strlen(str);
for(i=1;i<l;i++)
{
if(str[i]=='<')
{
count++;
}
if(str[i]=='>')
{
count--;
}
if(count==0)
{
len=(i+1);
if(str[i+1]=='>')
{
break;
}
}
}
cout<<len<<"\n";
}
}
}