zoj 1763 A Simple Question of Chemistry

A Simple Question of Chemistry


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Your chemistry lab instructor is a very enthusiastic graduate student who clearly has forgotten what their undergraduate Chemistry 101 lab experience was like. Your instructor has come up with the brilliant idea that you will monitor the temperature of your mixture every minute for the entire lab. You will then plot the rate of change for the entire duration of the lab.

Being a promising computer scientist, you know you can automate part of this procedure, so you are writing a program you can run on your laptop during chemistry labs. (Laptops are only occasionally dissolved by the chemicals used in such labs.) You will write a program that will let you enter in each temperature as you observe it. The program will then calculate the difference between this temperature and the previous one, and print out the difference. Then you can feed this input into a simple graphing program and finish your plot before you leave the chemistry lab.


Input

The input is a series of temperatures, one per line, ranging from -10 to 200. The temperatures may be specified up to two decimal places. After the final observation, the number 999 will indicate the end of the input data stream. All data sets will have at least two temperature observations.

Output

Your program should output a series of differences between each temperature and the previous temperature. There is one fewer difference observed than the number of temperature observations (output nothing for the first temperature). Differences are always output to two decimal points, with no leading zeroes (except for the ones place for a number less than 1, such as 0.01) or spaces.

After the final output, print a line with "End of Output"

Sample Input

10.0
12.05
30.25
20
999

Sample Output

2.05
18.20
-10.25
End of Output

分析:我只要前一个数,和当前的数就行了,就要想办法循环起来。不用容器存起来,当然用容器全部存起来在做也可以

 1 #include <iostream>
 2 using namespace std;
 3 int main(){
 4     cout.precision(2);
 5     double pre, cur;
 6     cin >> pre;
 7     if(pre == 999){
 8         cout << "End of Output" << endl;
 9         return 0;
10     }
11     while(cin >> cur){
12         if(cur == 999){
13             cout << "End of Output" << endl;
14             break;
15         }
16         cout << fixed << (cur - pre) << endl;
17         pre = cur;
18     }
19     //system("pause");
20     return 0;
21 }
时间: 2024-11-08 14:21:49

zoj 1763 A Simple Question of Chemistry的相关文章

poj2871 A Simple Question of Chemistry

A Simple Question of Chemistry Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6666   Accepted: 4426 Description Your chemistry lab instructor is a very enthusiastic graduate student who clearly has forgotten what their undergraduate Che

POJ 2871 A Simple Question of Chemistry(水题)

[题意简述]:后一个数减去前一个数并输出. [分析]:水 //208K 16Ms #include<iostream> using namespace std; int main() { double a; double b; bool flag = false; double ans; while(cin>>a) { if(a==999) { cout<<"End of Output"<<endl; break; } if(!flag)

ZOJ 3686 A Simple Tree Problem(线段树)

A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An

zoj 3686 A Simple Tree Problem (线段树)

Solution: 根据树的遍历道的时间给树的节点编号,记录下进入节点和退出节点的时间.这个时间区间覆盖了这个节点的所有子树,可以当做连续的区间利用线段树进行操作. /* 线段树 */ #pragma comment(linker, "/STACK:102400000,102400000") #include <iostream> #include <cstdio> #include <cstring> #include <cmath>

YTUOJ-A Simple Question

Description 今天,pasher打算在一个浪漫的花园和他的搭档们聚餐,但是不幸的是,pasher忘记了花园的地点,他只记得这个花园看上去像个平行于坐标轴的正方形,他还记得花园的每个顶点上都有一棵大数.现在,pasher知道其中两棵树的坐标,且这两棵树在对角线上,你能帮他找出另外两棵树的坐标吗? Input 多组输入,直到文件末.每组输入包含一行,第一行包含四个整数,x1,y1,x2,y2,代表pasher知道的两棵树的坐标,(-100<=x1,y1,x2,y2<=100),其中x1,

转摘&lt;&lt;On becoming an expert C programmer&gt;&gt;

The following is from an EMail message that I sent to to an individual on 12-Apr-2001. You may find this EMail message useful. The Writer asked: ``I just recently visited your website ... Just wanted to say greetings and ask a simple question: Do you

Python Base Two

//fourth day to study python 24. In python , how to create funcation. we can use def to define funcation. such as: def MyFirstFuncation(): print('this is my first funcation') MyFirstFuncation() -> this is my first funcatio. if there are no MyFirstFun

How to read a scientific paper

How to read a scientific paper Nothing makes you feel stupid quite like reading a scientific journal article. I remember my first experience with these ultra-congested and aggressively bland manuscripts so dense that scientists are sometimes caught e

越狱Season 1-Episode 21: Go

Season 1, Episode 21: Go -Michael: I need you to let me get us out of here. 我需要你帮我出去 -Patoshik: If you try to screw me over again, I'll kill you screw: [俚语]诈骗  again: 再一次 你再戏弄我,我就杀了你 -doctor: Because if crazy steps out of line, crazy: 疯狂的 step: 措施,举措