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
分析:我只要前一个数,和当前的数就行了,就要想办法循环起来。不用容器存起来,当然用容器全部存起来在做也可以
#include <iostream>
using namespace std;
int main(){
cout.precision();
double pre, cur;
cin >> pre;
if(pre == ){
cout << "End of Output" << endl;
return ;
}
while(cin >> cur){
if(cur == ){
cout << "End of Output" << endl;
break;
}
cout << fixed << (cur - pre) << endl;
pre = cur;
}
//system("pause");
return ;
}
zoj 1763 A Simple Question of Chemistry的更多相关文章
- A Simple Question of Chemistry
#include<stdio.h> int main() { int i, l; ]; ]; l = ; ) { l++; } ; a[i]!= && i<l; i+ ...
- YTU 2900: F-A Simple Question
2900: F-A Simple Question 时间限制: 1 Sec 内存限制: 128 MB 提交: 66 解决: 24 题目描述 今天,pasher打算在一个浪漫的花园和他的搭档们聚餐, ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- zoj 3286 Very Simple Counting---统计[1,N]相同因子个数
Very Simple Counting Time Limit: 1 Second Memory Limit: 32768 KB Let f(n) be the number of fact ...
- zoj 3686 A Simple Tree Problem (线段树)
Solution: 根据树的遍历道的时间给树的节点编号,记录下进入节点和退出节点的时间.这个时间区间覆盖了这个节点的所有子树,可以当做连续的区间利用线段树进行操作. /* 线段树 */ #pragma ...
- Simple Question
一.你会在时间序列数据集上使用什么交叉验证技术?是用k倍? 答:都不是.对于时间序列问题,k倍可能会很麻烦,因为第4年或第5年的一些模式有可能跟第3年的不同,而我们最终可能只是需要对过去几年的进行验证 ...
- ZOJ 3686 A Simple Tree Problem(线段树)
Description Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the ...
- K Simple question (第十届山东理工大学ACM网络编程擂台赛 正式赛)
题解:素数筛+唯一分解定理 可以把素数筛那部分放到while之外,减小时间复杂度. #include <stdio.h> #include <stdlib.h> #includ ...
- Functional Programming without Lambda - Part 1 Functional Composition
Functions in Java Prior to the introduction of Lambda Expressions feature in version 8, Java had lon ...
随机推荐
- 146 LRU Cache 最近最少使用页面置换算法
设计和实现一个 LRU(最近最少使用)缓存 数据结构,使它应该支持以下操作: get 和 put .get(key) - 如果密钥存在于缓存中,则获取密钥的值(总是正数),否则返回 -1.put(k ...
- codeblock 16.01
1.不希望for (int i = 1; i <= n; ++i) { } 中间按下去后,自动缩进到中间,只缩进到下一行. 可以去掉其中一个. 2.不自动完成,就是出现一个括号后不补充另一个. ...
- JDBC——入门知识【转】
1. 什么是JDBC:Java数据库连接性(JavaDatabase Connectivity) API,允许用户从Java应用程序中访问任何表格化数据源. 2. JDBC除了提供到更宽范围的SQ ...
- vue-resource emulateJSON的作用
如果Web服务器无法处理编码为application/json的请求,你可以启用emulateJSON选项. 启用该选项后,请求会以application/x-www-form-urlencoded作 ...
- javascript 找出数字数组中最大的数
找出数字数组中最大的数 var Match = (function(){ var arr = null; var len = 0; return { max:function(arr,len){ ar ...
- 使用kubeadm安装kubernetes v1.14.1
使用kubeadm安装kubernetes v1.14.1 一.环境准备 操作系统:Centos 7.5 ⼀ 一台或多台运⾏行行着下列列系统的机器器: Ubuntu 16.04+ Debi ...
- var、符号运算、条件语句、三元(目)运算、自加和自减
1.var a=“hello world” a 这个变量是字符串了,对于里面的每一个字母来说,他是字节,里面有11个字节,(包括空格),字节总数用length表示 2.符号运算 + 字符串拼接 . ...
- ArcGIS二次开发之读取遥感图像像素值的做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 首先是读取遥感图像的R.G.B波段数据的做法.读取R.G.B波段数据的像素值主要通过IRaster接口的Read方法在 ...
- 安装nginx的一些注意事项
1.如何彻底屏蔽掉Nginx的banner 为了安全或者某些个人的原因,如果要屏蔽掉nginx的banner,要修改以下几个位置: src/http/ngx_http_header_filter_mo ...
- VTK教程系列:VTK基础及应用开发教程
由于OpenCV不能使用,只能使用VTK库的图像处理库,暂时还没有找到其他可以全面替代的库: CSDN东灵工作室:http://blog.csdn.net/www_doling_net/article ...