美文网首页
PAT1012打卡-0912

PAT1012打卡-0912

作者: 可爱的甜甜猪 | 来源:发表于2020-09-13 11:24 被阅读0次

    #include <iostream>

    using namespace std;

    int main()

    {

    int n;

    int a[1000];

    int A1=0,A2=0,A3=0,A5=0;

    float A4=0;

    cin>>n;

    int a1=0,a2=0,a3=0,a4=0,a5=0;

    for(int i=0;i<n;i++)

    {

    cin>>a[i];

    }

    for(int i=0;i<n;i++)

    {

    if(a[i]%10==0)

    {

    A1=A1+a[i];

    a1++;

    }

    if(a[i]%5==1)

    {

    if(a2%2==0)

    {

    A2=A2+a[i];

    }

    else

    A2=A2-a[i];

    a2++;

    }

    if(a[i]%5==2)

    {

    a3++;

    A3++;

    }

    if(a[i]%5==4)

    {

    a5++;

    if(a[i]>A5)

    {

    A5=a[i];

    }

    }

    if(a[i]%5==3)

    {

    A4=A4+a[i];

    a4++;

    }

    }

    if(a4==0)

    {

    A4=0;

    }

    else

    A4=A4/a4;

    if(a1==0)

    cout<<'N'<<" ";

    else

    cout<<A1<<" ";

    if(a2==0)

    cout<<'N'<<" ";

    else

    cout<<A2<<" ";

    if(a3==0)

    cout<<'N'<<" ";

    else

    cout<<A3<<" ";

    if(a4==0)

    cout<<'N'<<" ";

    else

    {

    printf("%.1f",A4);

    cout<<" ";

    }

    if(a5==0)

    cout<<'N';

    else

    cout<<A5;

    return 0;

    }

    相关文章

      网友评论

          本文标题:PAT1012打卡-0912

          本文链接:https://www.haomeiwen.com/subject/elmbektx.html