Advertisement
Guest User

Find the cow

a guest
Oct 24th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1.    
  2.  
  3.     #include<iostream>
  4.     #include<cstdio>
  5.     #include<string>
  6.     #include<cstring>
  7.     using namespace std;
  8.     int main()
  9.     {
  10.     freopen("cowfind.in","r","stdin");
  11.     freopen("cowfind.out","w","stdout");
  12.         string s;
  13.         int len,res=0,cnt=0;
  14.         cin>>s;
  15.         len=s.size();
  16.         for(int i=0; i<len-1; i++)
  17.         {
  18.             if(s[i]=='(' && (s[i]==s[i+1]))cnt++;
  19.             else if(s[i]==')' && (s[i]==s[i+1]))
  20.             {
  21.                 res+=cnt;
  22.             }
  23.         }
  24.      
  25.         cout<<res<<endl;
  26.         return 0;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement