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.
- Plus Minus
- Discussions
Plus Minus
Plus Minus
Sort by
recency
|
264 Discussions
|
Please Login in order to post a comment
Here is a solution
def plusMinus(arr): # Write your code here cmax, cmin, czero=0,0,0 n=len(arr) for i in arr: if(i<0): cmin=cmin+1 if(i>0): cmax=cmax+1 if(i==0): czero=czero+1 print(f"{cmax/n:.6f}\n{cmin/n:.6f}\n{czero/n:.6f}")
done in python * countp, countn and countn is used to count nos of +ve, -ve and zero values. * ".6f" is used for precision( nos of digits after decimal point).
Hello All,
Can you help me I don't understand where is the problem in my code the output is wrong ,I always recieve Zero even if im trying to write 3 / 6 and Math.floorDiv
This is my Code and tank you public static void plusMinus(List arr) { // Write your code here int sizeList =arr.size(); long countPositive=0; long countNegative=0; long countZero=0; countPositive =arr.stream().filter(e->e>0).count(); System.out.println(Math.floorDiv(3, 6)); // System.out.printf("%f%n",countPositive/ sizeList);
countNegative =arr.stream().filter(e->e<0).count(); countZero =arr.stream().filter(e->e==0).count(); System.out.println(Math.floorDiv(countNegative, sizeList)); System.out.println(Math.floorDiv(countZero, sizeList)); System.out.println(countPositive ); System.out.println(countNegative ); System.out.println(countZero );
include
int main() { int n; double neg=0,pos=0,zero=0; scanf("%d",&n); int arr[n]; for(int i=0;i
}