We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
double a=0,b=0,c=0;
int arr[] = new int[n];
for(int arr_i=0; arr_i < n; arr_i++){
arr[arr_i] = in.nextInt();
}
for(int arr_i=0; arr_i < n; arr_i++){
if (arr[arr_i]>0)
{a++;}
else if (arr[arr_i]<0){b++;}
else if (arr[arr_i]==0){c++;}
}
System.out.println(a/n);
System.out.println(b/n);
System.out.println(c/n);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); double a=0,b=0,c=0; int arr[] = new int[n]; for(int arr_i=0; arr_i < n; arr_i++){ arr[arr_i] = in.nextInt(); }