fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. int[] input1 = new int[] {2,30,15,10,8,25,80};
  11. int input2 = 6;
  12. int countplus =0;
  13. int countnegative = 0;
  14. for(int i =0;i<input2;i++)
  15. {
  16. if(i<6)
  17. {
  18. if(input1[i]<=input1[i+1])
  19. {
  20. int savep = input1[i+1]-input1[i];
  21. countplus = countplus+savep;
  22.  
  23. }
  24. else {
  25. int saven = input1[i]-input1[i+1];
  26. countnegative = countnegative+saven;
  27.  
  28. }
  29. }
  30. else
  31. {
  32. System.out.println("");
  33. }
  34. }
  35. System.out.println(+countplus);
  36. System.out.println("negative");
  37. System.out.println(+countnegative);
  38. }
  39.  
  40. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
100
negative
22