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.
int l=arr.length;
int c=0,c1=0,c2=0;
for (int i = 0; i < l; i++) {
if(arr[i]>0){
c++;
}if(arr[i]<0){
c1++;
}if(arr[i]==0){
c2++;
}
}float a = ((float)c)/l;
System.out.println(a+"00000");
float x = ((float)c1)/l;
System.out.println(x+"00000");
float y = ((float)c2)/l;
System.out.println(y+"00000");
}
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 →
Try this.
static void plusMinus(int[] arr) {