Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <stack>
- using namespace std;
- int comb(int arriba,int abajo){
- if (abajo==0)
- return 1;
- if (abajo==1)
- return arriba;
- int aux=1;
- for (int i=abajo+1;i<=arriba;i++)
- aux=aux*i;
- for (int i=1;i<=(arriba-abajo);i++)
- aux=aux/i;
- return aux;
- }
- int main() {
- string s;
- while(getline(cin,s)){
- stack<char>p;
- int correcto=1;
- for(int i=0;i<s.size();i++){
- if (s[i]=='(')
- p.push(s[i]);
- else if (s[i]==')'){
- if (p.empty() || p.top()!='('){
- correcto=0;
- break;}
- else
- p.pop();
- }
- }
- if (p.empty() && correcto)
- cout<<"correct"<<endl;
- else
- cout<<"incorrect"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment