zoj1763-----------A Simple Question of Chemistry

编程入门 行业动态 更新时间:2024-10-21 15:59:55
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




代码:

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

int main()
{
	float x,y;
	cin>>x;
	while(cin>>y)
	{		
		if(y==999)
		{
			cout<<"End of Output"<<endl;
			break;
		}
		else
		{
			printf("%.2f\n",y-x);
			x=y;
		}	
	}
	return 0;
}




更多推荐

zoj1763-----------A Simple Question of Chemistry

本文发布于:2023-06-13 08:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Simple   Chemistry   Question

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!