Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public boolean sprawdzanie (String tekst) {
  2. Stos stosik = new Stos ();
  3. for (int i=0;i<(tekst.length());i++)
  4. {
  5. if (tekst.charAt(i)=='(') stosik.push(tekst.charAt(i));
  6.  
  7. else if (!stosik.isEmpty()&&tekst.charAt(i)==')') stosik.pop();
  8. else
  9. {
  10. System.out.println("NIE");
  11. return false;
  12. }
  13. }
  14. if (isEmpty())
  15. { System.out.println("TAK");
  16. return true;
  17. }
  18. else
  19. {
  20. System.out.println("NIE");
  21. return false;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement