Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 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. }
  14. if (str[i] == ')') {
  15. c_b++;
  16. }
  17. }
  18. if (o_b == c_b)
  19. cout << "the number of opening brackets and closing brackets are equal" << endl;
  20. else
  21. cout << "the number of opening brackets and closing brackets are not equal" << endl;
  22. system("pause");
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement