Tuesday, October 15, 2013

uri online judge 1006 solution in c++

uri online judge 1006 solution in c++

here is uri online judge 1006 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1006

Average 2

Read three numbers (variables A, B and C), which are the test scores of a student. Then, calculate the average, knowing that the note A has a weight of 2, the note B has a weight of 3 and the note C has a weight of 5. Consider that each note can go from 0 to 10.0, always with one decimal place.

Input

The input file contains 3 floating-point numbers with one digit after the decimal point.

Output

Print MEDIA(average in portuguese) according to the following example, with a blank space before and after the equal signal.
Sample InputSample Output
5
6
7
MEDIA = 6.3
 and here is my c++ solution to uri online judge 1006: http://ideone.com/w8z8gX

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
float A, B, C, MEDIA;
cin >> A >> B >> C;
MEDIA = ((A * 2) + (B * 3) + (C * 5)) / (2 + 3 + 5);
cout << fixed << setprecision(1);
cout << "MEDIA = " << MEDIA << endl;
return 0;
}

2 comments:

  1. Solution for the following program:
    Write two overloaded functions that return the average of an array with the following headers: [10]

    int average(int * array, int size)

    double average (double * array, int size)


    Use { 1,2,3,4,5,6} and {6.0,4.4,1.9,2.9,3.4,3.5}

    ReplyDelete
    Replies
    1. i didnt quite get that. can you pls explain clearly? thnx

      Delete