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.
- Prepare
- Algorithms
- Warmup
- Plus Minus
- Discussions
Plus Minus
Plus Minus
Sort by
recency
|
3195 Discussions
|
Please Login in order to post a comment
Plus Minus has its pros and cons, but when it comes to reliable service, you always want the best. If you're looking for expert plumbing contractors Philadelphia, make sure to choose a team that knows the ins and outs of the job. A good plumber can save you from big headaches down the road! Who do you trust for plumbing work in Philly?
Language: JAVA 15
In this problem We have to print the ratios of positive, negative and zero values with 6 digits after the decimal. To solve this problem I used printf() with format specifier
///Java Solution
class Result { public static void plusMinus(List arr) { double countpos=0, countneg=0, countzero=0; double n=arr.size(); for(int i=0;i 0){ countpos++; } else if(arr.get(i) < 0){ countneg++; } else if(arr.get(i)==0){ countzero++; } }
}
n = int(input().strip()) arr = [1 if int(temp)>0 else -1 if int(temp)<0 else 0 for temp in input().strip().split(' ') ] print("{0:.6f}".format(arr.count(1)/n)) print("{0:.6f}".format(arr.count(-1)/n)) print("{0:.6f}".format(arr.count(0)/n))