➽ Problem:-
https://www.hackerrank.com/challenges/plus-minus/problem
➽ Solution:-
#include
<assert.h>
#include
<limits.h>
#include
<math.h>
#include
<stdbool.h>
#include
<stddef.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
int main()
{
int N, arr[1000];
float count1=0, count2=0, count3=0;
scanf("%d", &N);
for(int i=0; i<N; i++)
{
scanf("%d", &arr[i]);
if(arr[i]>0)
count1++;
else if(arr[i]<0)
count2++;
else
count3++;
}
printf("%f\n%f\n%f", count1/N,
count2/N, count3/N);
return 0;
}
0 Comments
Please do not enter any spam link in the comment section.