Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- int count_of_positives = 0;
- int sum_of_negatives = 0;
- ArrayList<Integer> positives = new ArrayList<Integer>();
- ArrayList<Integer> negatives = new ArrayList<Integer>();
- for (int i = 0; i < n ; i++){
- int numbers = input.nextInt();
- if(numbers>=0){
- positives.add(numbers);
- count_of_positives++;
- } else{
- negatives.add(numbers);
- sum_of_negatives+=numbers;
- }
- }
- System.out.println(positives);
- System.out.println(negatives);
- System.out.println("Count of positives: " + count_of_positives);
- System.out.println("Sum of negatives: " + sum_of_negatives);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement