➽ Problem:-
https://www.hackerrank.com/challenges/plus-minus/problem
➽ Solution:-
#include<bits/stdc++.h>
using
namespace std;
int main()
{
int N;
cin>>N;
int arr[N];
for(int i=0;i<N;i++)
{
cin>>arr[i];
}
int count1=0,count2=0,count3=0;
for(int i=0;i<N;i++)
{
if(arr[i]>0)
count1++;
if(arr[i]<0)
count2++;
if(arr[i]==0)
count3++;
}
cout<<setprecision(6)<<(float)count1/N<<endl;
cout<<setprecision(6)<<(float)count2/N<<endl;
cout<<setprecision(6)<<(float)count3/N<<endl;
return 0;
}
0 Comments
Please do not enter any spam link in the comment section.