URI / BEE CROWD 1079 - Weighted Averages Solution in C,C++,Python | URI - BEECROWD - BEE 1079 Solution in C,C++,Python
beecrowd | 1079
Weighted Averages
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1Adapted by Neilor Tonin, URI Brazil
Read an integer N, which represents the number of following test cases. Each test case consists of three floating-point numbers, each one with one digit after the decimal point. Print the weighted average for each of these sets of three numbers, considering that the first number has weight 2, the second number has weight 3 and the third number has weight 5.
Input
The input file contains an integer number N in the first line. Each N following line is a test case with three float-point numbers, each one with one digit after the decimal point.
Output
For each test case, print the weighted average according with below example.
Input Sample | Output Sample |
3 | 5.7 |
URI / BEE CROWD 1079 - Weighted Averages Solution in C,C++,Python | URI - BEECROWD - BEE 1079 Solution in C,C++,Python
Demonstration:
URI / BEE 1079 Solution in C :
URI / BEECROWD Online Judge 1079 Solve in C : |
#include<stdio.h>
int main()
{
int n,i;
float a,b,c,sum,avg;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%f %f %f",&a,&b,&c);
sum=a*2+b*3+c*5;
avg=sum/(2+3+5);
printf("%.1f\n",avg);
}
return 0;
}
0 Response to URI / BEE CROWD 1079 - Weighted Averages Solution in C,C++,Python | URI - BEECROWD - BEE 1079 Solution in C,C++,Python
Post a Comment