三楼正解!
#include <iostream>
using namespace std;
int cal_score(int score[],int judge_type[],int n)
{
int n_zhuangjia=0;
int s_zhuangjia=0;
int s_dazhong=0;
int pingjun=0;
for(int i=0;i<n;i++)
{
if (1==judge_type[i])
{
s_zhuangjia+=score[i];
n_zhuangjia++;
}
else if (2==judge_type[i])
{
s_dazhong+=score[i];
}
}
if (n_zhuangjia>0&&n_zhuangjia<n)
{
pingjun=(int)(s_zhuangjia/n_zhuangjia*0.6+s_dazhong/(n-n_zhuangjia)*0.4);
}
else if (n_zhuangjia==n)
{
pingjun=(int)(s_zhuangjia/n*0.6);
}
else if (n_zhuangjia==0)
{
pingjun=(int)(s_dazhong/n*0.4);
}
return pingjun;
}
void fun(int a[],int m)
{
for(int i=0;i<m;i++)
a[i]=100;
}
void print1(int a[],int m)
{
for(int i=0;i<m;i++)
cout<<a[i]<<endl;
}
void main()
{
int score[]={12,34,23,56,90,26,87,98,100,85};
int judge_type[]={1,1,1,1,1,2,2,2,2,2};
//
print1(score,10); //right
//
print1(judge_type,10);
int number=0;
fun(score,10);
//
cout<<score[0];
number=cal_score(score,judge_type,10);
cout<<number<<endl;
}