Wednesday, December 2, 2015

Uri problem 1014 solve

Problem :

Consumption

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Calculate the average consumption of a car given the total distance traveled (in Km) and the total spent fuel (in liters).

Input

The input file contains two numbers: the first one is an integer which represents the total distance (in Km) and the second one is an floating-point number Y  which represents the among of spent fuel by the car, with a digit after the decimal point.

Output

Print the result which represents the medium of the car comsumptiom with 3 digits after the decimal point, followed by the message "km/l".
Sample InputSample Output
500
35.0
14.286 km/l
2254
124.4
18.119 km/l
4554
464.6
9.802 km/l

Solution:


#include <stdio.h>
  
int main() {
  
int X;
    float Y ,cojumption ;
    scanf("%d %f",&X,&Y);
    cojumption = (X/Y) ;
    printf("%.3f km/l\n",cojumption);
  
    return 0;
}

No comments:

Post a Comment