华为机试:专家判分

来源:互联网 发布:mac和windows快捷键 编辑:程序博客网 时间:2024/05/16 11:23
#include <iostream>using namespace std;int finalscor(int score[],int len,int judge_type[]){int sum1=0,sum2=0;int count1=0,count2=0;for(int i=0;i<len;++i){if(judge_type[i]==1){sum1+=score[i];count1++;}else if(judge_type[i]==2){sum2+=score[i];count2++;}}int ave1=sum1/count1;int ave2=sum2/count2;int fin=0;if(ave2==0)fin=ave1;elsefin=ave1*0.6+ave2*0.4;return fin;}int main(){int score[1024]={0};int judge_type[1024]={0};int a,k=0,b,l=0;cin>>a;while(getchar()!='\n'){score[k++]=a;cin>>a;}
<span style="white-space:pre"></span><pre name="code" class="cpp">        score[k++]=a;
cin>>b;while(getchar()!='\n'){judge_type[l++]=b;cin>>b;}
<pre name="code" class="cpp">        judge_type[l++]=b;
int res=finalscor(score,k,judge_type);cout<<res;return 0;}

0 0
原创粉丝点击