2018.9.7讯飞笔试 软件开发工程师两道编程题
2018.9.7讯飞笔试 软件开发工程师两道编程题AC答案(C++): 第一题: 修改成绩:#include <iostream> #include <numeric> #include <algorithm> using namespace std; int main(){ int T; while(cin>>T){ int n,X; for(int i=0;i<T;i++){ cin>>n>>X; int a; vector<int> test; for(int i=0;i<n;i++){ cin>>a; test.push_back(a); } int sum=accumulate(test.begin(),test.end(),0); int target=n*X; int count=0; sort(test.begin(),test.end()); if(target<=sum){ cout<<count<<endl; } else for(auto temp=test.begin();temp!=test.end();temp++){ sum=sum+100-(*temp); count++; if(target<=sum){ cout<<count<<endl; break; } } } } return 0; }第二题 杀手: #include <iostream> #include <numeric> #include <algorithm> using namespace std; int main(){ int n; while(cin>>n){ vector<int> test; for(int i=0;i<n;i++){ int a; cin>>a; test.push_back(a); } int count=0; while(test.size()>1){ vector<int> temp; temp.push_back(test[0]); for(int i=1;i<test.size();i++){ if(test[i]>=test[i-1]){ temp.push_back(test[i]); } } if(temp.size()==test.size()){ break; } count++; test=temp; } cout<<count<<endl; } return 0; }
#笔试题目##科大讯飞##秋招#