内存:128  时间:1

题目描述

The Fourth Voice of China is coming. It will apply a new rule to determine the champion. There are four judges in charge of scoring for the singer, each judge giving a score Si and a weight Wi, the weighted  score of each judge is Si*Wi. For each singer, the final score is the sum of four judges’ weighted score. Can you write a program to calculate the final score?

输入

The first line of the input contains two integers N and M(1<=N<=20, 1<=M<=50) . N means the number of test cases and M means the number of candidates. The second line cinsists of 4 decimals (0<w1, w2, w3, w4<1) which represent the judges’ weights . Then the follows  are M lines, each line consisting of 4 integers (0<=s1, s2, s3, s4<= 100) which represent judges’ scores.

输出

For each case, output the integer part of the final scoreof every candidates for each line.

样例输入

1 2
0.2 0.3 0.1 0.4
78 88 79 80
83 89 87 79

样例输出

81
83

提示

代码如下

#include <stdio.h>
int main()
{
    int n, m,i,j,a[100][100],k;
    double b[100],sum[100];
    scanf("%d",&n);
    for(k=0;k<n;k++)
    {
        scanf("%d",&m);
        for(i=0;i<4;i++)
        {
            scanf("%lf",&b[i]);
        }
        for(i=0;i<m;i++)
        {
            sum[i]=0;
            for(j=0;j<4;j++)
            {
                scanf("%d",&a[i][j]);
                sum[i]+=a[i][j]*b[j];
            }
            printf("%d
",(int)sum[i]);
        }
    }
    return 0;
}

代码来源于互联网,仅供参考!