Code Monkey home page Code Monkey logo

Comments (3)

liuchuo avatar liuchuo commented on August 15, 2024

感谢提出质疑
但是我还是有点儿疑问
关于第一个问题:我在分析中的第三点这样阐述 [ 3.注意,平均分是四舍五入的,所以需要按照+0.5后取整,保证是四舍五入的(听说不四舍五入也能通过…)]
因为平均成绩本身按照四舍五入来说才是正确的,题目中如果真的无需四舍五入的话应该具体说明【For the sake of simplicity, xxxxxx】这样的话,否则逻辑上是不通的
关于第二个问题:题目中[each contains a student ID which is a string of 6 digits] 题目中这句话不是表明是6位数字的意思么

from pat.

UNICKCHENG avatar UNICKCHENG commented on August 15, 2024

其实第一个问题,题目中也没细说,对于是否需要四舍五入,产生疑问是肯定的(不管是否四舍五入也都可以通过...),而第二个问题,是我审题不清(好尴尬呀~),谢谢指正

from pat.

martianmartian avatar martianmartian commented on August 15, 2024

#include<iostream>
#include<vector>
using namespace::std;

int main(){

  int N; cin>>N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }
  // vector<int> v={13,1,2,3,4,5,6,7,8,9,10,20,16,18};
  // vector<int> v={8,1,2,4,5,6,7,9,16};

  int A[5]={0}; bool test[5]={false};
  int sign=-1;
  int cout3=0;
  int mx=-1000;
  
  for(auto x:v){

    if(x%5==0&x%2==0){
      A[0]+=x;
      test[0]=true;
    };
    if(x%5==1){
      sign *= (-1);
      A[1]+=(x * sign);
      test[1]=true;
    }
    if(x%5==2){
      A[2]++;
      test[2]=true;
    }
    if(x%5==3){
      A[3]+=x;
      cout3++;
      test[3]=true;
      // cout<<x<<" ";
    }
    if(x%5==4){
      if(x>A[4]){
        A[4]=x;
        test[4]=true;
      };
    }
  }
  
  test[0]?cout<<A[0]<<" ":cout<<"N"<<" ";
  test[1]?cout<<A[1]<<" ":cout<<"N"<<" ";
  test[2]?cout<<A[2]<<" ":cout<<"N"<<" ";
  
  test[3]?printf("%.1f ",float(A[3])/cout3):printf("%s ","N");

  test[2]?cout<<A[4]:cout<<"N";


  return 0;
}

你可以用这个答案,但是需要找到为啥有一点过不去。。。。。

from pat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.