Quantcast
Channel: Uva @ FCFM Blog
Viewing all articles
Browse latest Browse all 10

10137 – The Trip

$
0
0

Problem Description, Input and Output:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=29&page=show_problem&problem=1078

 

This one is not too difficult you need to calculate the sum of the cost above the average price and also the sum of the costs below the average. The number you print is the higher of the two.

like you need to use double data type to use the decimal part of the numbers but you only need 2 digits after the decimal point you need to “round” the number, you can do it this way:

(double)((long)(price – avg)*100)/100

that way you eliminate all the digits after the second spot.

REMEMBER TO OUTPUT THE “$” CHARACTER !!!!

The Trip

source code


Viewing all articles
Browse latest Browse all 10

Trending Articles