Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. void main()
  7. {
  8. char a;
  9. int open(0), close(0);
  10. ifstream f("text.txt", ios::in);
  11. if (f)
  12. {
  13. while (f)
  14. {
  15. f.get(a);
  16. if (a == '(')
  17. open++;
  18. if (a == ')')
  19. close++;
  20. a = ' ';
  21. }
  22. cout << "( = " << open << "\n) = " << close << "\n";
  23. if (open == close)
  24. cout << "Correct code\n";
  25. else
  26. cout << "Uncorrect code\n";
  27. }
  28. else cout << "Error input file\n";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement