➽ Problem:-
https://www.hackerrank.com/challenges/plus-minus/problem
➽ Solution:-
import
java.util.*;
import
java.io.*;
import
java.math.*;
import
java.security.*;
import
java.text.*;
import
java.util.concurrent.*;
import
java.util.regex.*;
public class
Solution
{
public static void main(String args[])
{
int N;
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
int arr;
float count1=0, count2=0, count3=0;
for(int i=0; i<N; i++)
{
arr = sc.nextInt();
if(arr>0)
count1++;
else if(arr<0)
count2++;
else
count3++;
}
System.out.println(count1/N);
System.out.println(count2/N);
System.out.println(count3/N);
}
}
0 Comments
Please do not enter any spam link in the comment section.