Skip to content

Instantly share code, notes, and snippets.

@codyhex
Created October 24, 2017 22:51
Show Gist options
  • Save codyhex/3b0f4bc49a3a2287793ad6cf530b118e to your computer and use it in GitHub Desktop.
Save codyhex/3b0f4bc49a3a2287793ad6cf530b118e to your computer and use it in GitHub Desktop.
using namespace std;
int main() {
int n;
cin >> n;
double pl = 0, mn = 0, zr = 0;
for (int i = 0; i < n; i++) {
int val;
cin >> val;
zr += (val == 0);
pl += (val > 0);
mn += (val < 0);
}
zr = zr / (double)n;
pl = pl / (double)n;
mn = mn / (double)n;
// prints 0.123456
printf("%0.06lf\n%0.06lf\n%0.06lf\n", pl, mn, zr);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment