Guest User

Untitled

a guest
Sep 14th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public class JavaApplication8 {
  2. public static int str(String gdzie, String co)
  3. {
  4. int a = co.length();
  5. int b =0;
  6. boolean c = false;
  7.  
  8. for (int i=0;i<gdzie.length()-co.length();i++)
  9. {
  10. if (c = false)
  11. {
  12. a = co.length();
  13. }
  14. int j =0;
  15.  
  16. for (j=0;j<co.length();j++)
  17. {
  18. if (gdzie.charAt(i+j) == co.charAt(j))
  19. {
  20. c = true;
  21. a= a-1;
  22. System.out.println(a);
  23. }
  24. else
  25. {
  26. c = false;
  27. }
  28. if (a == 0)
  29. {
  30. b+=1;
  31. a = co.length();
  32.  
  33. }
  34.  
  35. }
  36. }
  37. System.out.println(b);
  38. return b;
  39. }
  40. /**
  41. * @param args the command line arguments
  42. */
  43. public static void main(String[] args) {
  44. // TODO code application logic here
  45. str("Ala ma kota ma kota ma mama","ma");
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment