博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2871 A Simple Question of Chemistry(我的水题之路——数列两数之差 )
阅读量:4069 次
发布时间:2019-05-25

本文共 2299 字,大约阅读时间需要 7 分钟。

A Simple Question of Chemistry
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5647   Accepted: 3757

Description

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.012.0530.2520999

Sample Output

2.0518.20-10.25End of Output

Source

给一列数,从第二个数开始,输出其与上一个数字之差,输出取两位小数,输入以“999”数字结束。
找一个变量last存储前一个数,然后读入当前数now,输出其之差,再将当前数now赋值给前一数变量last。
代码(1AC):
#include 
#include
#include
int main(void){ float last = 0, now; scanf("%f", &last); while (last != 999 && scanf("%f", &now), now != 999){ printf("%.2f\n", now - last); last = now; } printf("End of Output\n"); return 0;}

转载地址:http://yloji.baihongyu.com/

你可能感兴趣的文章
Android2.1消息应用(Messaging)源码学习笔记
查看>>
剑指offer算法题分析与整理(三)
查看>>
JVM并发机制探讨—内存模型、内存可见性和指令重排序
查看>>
nginx+tomcat+memcached (msm)实现 session同步复制
查看>>
WAV文件解析
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
QT打开项目提示no valid settings file could be found
查看>>
android 代码实现圆角
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
多线程使用随机函数需要注意的一点
查看>>
getpeername,getsockname
查看>>
Visual Studio 2010:C++0x新特性
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>