【Basic Level】
*1012 输出N的条件判断
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip> // cout << setiosflags(ios::fixed) << setprecision(n);
using namespace std;
int main()
{
int n = 0;
cin >> n;
int a = 0, b = 0, c = 0, f = 0;
int t = 0;
float d = 0.0, x = 0.0;
for (int i = 0, m = 0, flag = 1; i < n; i++)
{
cin >> m;
switch (m % 5)
{
case 0:
if (m % 2 == 0)
a += m;
break;
case 1:
if (flag)
{
b = b + m;
flag = 0;
}
else
{
b = b - m;
flag = 1;
}
break;
case 2:
c++;
break;
case 3:
d += m;
x++;
break;
case 4:
f = m > f ? m : f;
break;
default:
break;
}
}
if (a != 0) cout << a << " ";
else cout << "N ";
if (t) cout << b << " ";
else cout << "N ";
if (c != 0) cout << c << " ";
else cout << "N ";
if (d != 0) cout << setiosflags(ios::fixed) << setprecision(1) << d / x << " ";
else cout << "N ";
if (f != 0) cout << f << endl;
else cout << "N" << endl;
//system("pause");
return 0;
}