Problem Description
source:https://uva.onlinejudge.org/external/119/p11984.html
Measuring temperature and temperature differences are common task in many research and applications. Unfortunately, there exists more than one unit of measuring temperatures. This introduces a lot of confusion at times. Two popular units of measurements are Celsius(C) and Fahrenheit (F). The conversion of F from C is given by the formula
F = (9 / 5) * C + 32
In this problem, you will be given an initial temperature in C and an increase in temperature in F. You would have to calculate the new temperature in C.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases. Each case contains a line with two integers C and d (0 ≤ C, d ≤ 100), where C represents the initial temperature in Celsius and d represents the increase in temperature in Fahrenheit.
Output
For each case, print the case number and the new temperature in Celsius after rounding it to two digits after the decimal point.
Sample Input
2
100 0
0 100
Sample Output
Case 1: 100.00
Case 2: 55.56
Solution :
Measuring temperature and temperature differences are common task in many research and applications. Unfortunately, there exists more than one unit of measuring temperatures. This introduces a lot of confusion at times. Two popular units of measurements are Celsius(C) and Fahrenheit (F). The conversion of F from C is given by the formula
F = (9 / 5) * C + 32
In this problem, you will be given an initial temperature in C and an increase in temperature in F. You would have to calculate the new temperature in C.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases. Each case contains a line with two integers C and d (0 ≤ C, d ≤ 100), where C represents the initial temperature in Celsius and d represents the increase in temperature in Fahrenheit.
Output
For each case, print the case number and the new temperature in Celsius after rounding it to two digits after the decimal point.
Sample Input
2
100 0
0 100
Sample Output
Case 1: 100.00
Case 2: 55.56
Solution :
#include <algorithm> #include <cstdio> #include <cmath> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include<stdio.h> #include<stdlib.h> using namespace std; int main() { int t,i; float c,f,diff,c1; while(scanf("%d",&t)==1) { for(i=1;i<=t;i++) { scanf("%f%f",&c,&f); c1=(5.0*f)/9.0; diff=c+c1; printf("Case %d: %.2f\n",i,diff); } } return 0; }
No comments:
Post a Comment
Write your comment - Share Knowledge and Experience