Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a=input('Введите строку: ')
- max=-1
- for i in range(len(a)):
- counter=0
- count1=0
- count2=0
- count3=0
- for j in range(i,len(a)):
- if a[j]=='(':
- count1+=1
- if a[j]=='[':
- count2+=1
- if a[j]=='{':
- count3+=1
- if a[j]==')':
- count1-=1
- if a[j]==']':
- count2-=1
- if a[j]=='}':
- count3-=1
- counter+=1
- if count1<0 or count2<0 or count3<0:
- break
- if count1==0 and count2==0 and count3==0 and counter>max:
- max=counter
- start=i+1
- end=j+1
- print('Длина: ',max,'Начало: ',start,'Конец: ',end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement