Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main(){
  5. char str[100];
  6. int i,o_b,c_b;// o_b - opening bracket; c_b - closing bracket.
  7. cout << "Input string, please:" << endl;
  8. cin >> str[100];
  9. o_b=c_b=0;
  10. for (i=0;i <=strlen(str);i++){
  11. if (str[i] == '(')
  12. o_b++;
  13. if (str[i] == ')')
  14. c_b++;
  15. }
  16. if (o_b == c_b)
  17. cout << "the number of opening brackets and closing brackets are equal" << endl;
  18. else
  19. cout << "the number of opening brackets and closing brackets are not equal" << endl;
  20. system("pause");
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement