fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) //no of ways to divide array in two equal parts
  11. import java.util.*;
  12. public class Main
  13. {
  14. public static void main(String[] args) {
  15. Scanner sc = new Scanner(System.in);
  16. int n=sc.nextInt();
  17. int[]nums = new int[n];
  18.  
  19. for(int i=0;i<n;i++){
  20. nums[i]=sc.nextInt();
  21. }
  22. int tot_sum=0;
  23. for(int i=0;i<n;i++){
  24. tot_sum+=nums[i];
  25. }
  26. int lhs=0;
  27. int rhs=0;
  28. int count=0;
  29. if(tot_sum%2 ==0){
  30. for(int i=0;i<n;i++){
  31. lhs+=nums[i];
  32. rhs=tot_sum-lhs;
  33. if(lhs == tot_sum/2){
  34. count++;
  35. }
  36. }
  37. }
  38. System.out.print("Number of ways to divide in two equal parts :" + count);
  39. }
  40. } java.lang.Exception
  41. {
  42. // your code goes here
  43. }
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:10: error: ';' expected
	public static void main (String[] args) //no of ways to divide array in two equal parts
	                                       ^
Main.java:40: error: <identifier> expected
} java.lang.Exception
                     ^
2 errors
stdout
Standard output is empty