1012 数字分类 测试点8
作者:互联网
易错点
测试点8:A2的和为零但不为空的情况
代码
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
int a[1002];
int main()
{
int n;
int cnt1=0;
int cnt2=0;
int cnt22=0;
int tmp2=1;
int cnt3=0;
int cnt41=0;
int cnt42=0;
int max5=-1;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
if(a[i]%5==0){
if(a[i]%2==0){
cnt1+=a[i];
}
}
if(a[i]%5==1){
cnt2=cnt2+a[i]*tmp2;
tmp2=tmp2*(-1);
cnt22++;
}
if(a[i]%5==2){
cnt3++;
}
if(a[i]%5==3){
cnt41+=a[i];
cnt42++;
}
if(a[i]%5==4){
if(max5<a[i]){
max5=a[i];
}
}
}
if(cnt1==0){
cout<<"N"<<" ";
}
else{
cout<<cnt1<<" ";
}
if(cnt22==0){
cout<<"N"<<" ";
}
else{
cout<<cnt2<<" ";
}
if(cnt3==0){
cout<<"N"<<" ";
}
else{
cout<<cnt3<<" ";
}
if(cnt41==0){
cout<<"N"<<" ";
}
else{
cout<<fixed<<setprecision(1)<<float(cnt41)/float(cnt42)<<" ";
}
if(max5<=0){
cout<<"N";
}
else{
cout<<max5;
}
return 0;
}
标签:测试点,int,分类,++,cnt2,include,1012,tmp2 来源: https://www.cnblogs.com/wodeblog1982/p/16483921.html