0

PlusMinus [ A New Challenge To All ]

Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to 10^-4 are acceptable. For example, given the array arr=[1,1,0,-1,-1] there are 5 elements, two positive, two negative and one zero. Their ratios would be 2/5=0.400000 ,2/5=0.400000, 1/5=0.200000 and . It should be printed as: 0.400000 0.400000 0.200000 Input Format: The first line contains an intege n , denoting the size of the array. The second line contains n space-separated integers describing an array of numbers Output: You must print the following 3 lines: 1) A decimal representing of the fraction of positive numbers in the array compared to its size. 2) A decimal representing of the fraction of negative numbers in the array compared to its size. 3) A decimal representing of the fraction of zeros in the array compared to its size.

9th Oct 2019, 6:55 AM
m8riix
m8riix - avatar
3 Respostas
0
1) This is not the place to post challenges, rather do so in your feed 2) https://code.sololearn.com/cWd32cL1q94l/?ref=app
9th Oct 2019, 7:40 AM
Trigger
Trigger - avatar
0
Robin which lang is this 👍🏻
9th Oct 2019, 9:28 AM
m8riix
m8riix - avatar
0
ok 👍🏻
9th Oct 2019, 10:53 AM
m8riix
m8riix - avatar