Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
4,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public class test {
  2.  
  3. public static void main(String[] args) {
  4. String str = "Какой-то текст для примера";
  5. int max = 0;
  6. int chetchik = 0;
  7. char sim = 'т';
  8. max = str.length();
  9. for (int i = 0; i < max; i++){
  10. if (str.charAt(i) == sim) chetchik = chetchik + 1;
  11. if (chetchik > 1) {
  12. System.out.print("Символ повторяется 2 раза");
  13. break;
  14. }
  15. }
  16. if (chetchik < 2) System.out.print("Символ не повторяется более 2 раз");
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement