Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- static int massive(int[] work){
- int tempo = 0;
- for (int i = 0; i < work.length; i++) {
- tempo = work[i];
- if (tempo > 0) {
- return tempo;
- }
- else{
- tempo +=work[i];
- }
- }
- return tempo;
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] work = new int[] {-3,-24,-25};
- int tempo = massive(work);
- if(tempo < 0){
- System.out.println(tempo);
- }
- else{
- System.out.println("stupid");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement