Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Demo {
  4.  
  5. static int massive(int[] work){
  6. int tempo = 0;
  7. for (int i = 0; i < work.length; i++) {
  8. tempo = work[i];
  9. if (tempo > 0) {
  10. return tempo;
  11. }
  12. else{
  13. tempo +=work[i];
  14. }
  15. }
  16. return tempo;
  17. }
  18.  
  19. public static void main(String[] args) {
  20. Scanner scanner = new Scanner(System.in);
  21. int[] work = new int[] {-3,-24,-25};
  22. int tempo = massive(work);
  23. if(tempo < 0){
  24. System.out.println(tempo);
  25. }
  26. else{
  27. System.out.println("stupid");
  28. }
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement