xxZeus

asf

Apr 6th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.*;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class Main
  6. {
  7. public static Scanner in = new Scanner(System.in);;
  8. int ar[];
  9. int n;
  10. int c;
  11. int sum(int s, int f)
  12. {
  13. int sum = 0;
  14. for(int i = s; i < f; i++)sum += ar[i];
  15. return sum;
  16. }
  17. void init(int n)
  18. {
  19. this.n = n;
  20. ar = new int[n];
  21. c = 0;
  22. }
  23. void read()
  24. {
  25. in.nextLine();
  26. String s = in.nextLine();
  27. String sp[] = s.split("[ ]");
  28. for(int i = 0;i < n; i++)ar[i] = Integer.parseInt(sp[i]);
  29. }
  30.  
  31. void doJob()
  32. {
  33. for(int i = 1; i < n-1;i++)
  34. {
  35. if(sum(0, i) == sum(i, n)){ c++; }
  36. }
  37. }
  38.  
  39. public static void main()
  40. {
  41. System.out.println("enter input");
  42. int j = in.nextInt();
  43. Main ob = new Main();
  44. ob.init(j);
  45. ob.read();
  46. ob.doJob();
  47. System.out.println(ob.c);
  48. }
  49. }
Add Comment
Please, Sign In to add comment