第第三章练习

【题目描述】

已知某班有男生n1位,女生n2位,n1位男生的平均分是x分,n2位女生的平均分是y分,问全体学生的平均分是多少?

【输入】

4个整数x、y、n1、n2。

【输出】

全体学生的平均分,结果保留0小数。提示:可以用“%.0f”输出结果。

【样例输入】

90 88 23 21↙

【样例输出】

ave=89
#include <stdio.h>
#include <stdlib.h>
//#define PI 1.609
int main()
{
    double x,y,n1,n2;
    double pj;
    scanf("%lf%lf%lf%lf",&x,&y,&n1,&n2);
    pj=(x*n1+y*n2)/(n1+n2);
    printf("ave=%.0lf",pj);
    return 0;
}

 

posted @ 2022-10-01 20:29  aquAAA  阅读(119)  评论(0编辑  收藏  举报