zoj 1745 Are We There Yet?
来源:互联网 发布:大数据时代读后感5000 编辑:程序博客网 时间:2024/05/17 10:27
#include<iostream>#include<string>#include<cmath>using namespace std;string status(int*, int Pos, int i);const int end = 5280; // no more input if the first input is endconst int size = 21;int main() { int cookiePos, a[size], isBetween = -1; while(cin >> cookiePos && cookiePos != end) { isBetween++; if(isBetween) cout << endl; for (int i = 0; i < size; ++i) { a[i] = 0; } // init value int step = 1; while (cin >> a[step] && a[step] != cookiePos) { step++; } //a[step] == cookiepos when after loop for (int i = 1; i <= step; ++i) { cout << "Moving from "<< a[i-1] << " to " << a[i] << ": " << status(a, cookiePos, i) << endl; } } return 0;}string status(int* a, int Pos, int i){ int last = abs(a[i-1] - Pos); int now = abs(a[i] - Pos); // todo cast!! // string res = ""; if (now == 0 ) { return "found it!"; } else if (now == last) { return "same."; } else if (now > last) { return "colder."; } else { return "warmer."; }}
always got a presentation error. Fortunately, referring to other's code, then I know I shoulda give a space between two blocks, neither can be at the beginning nor the end of the whole thing
0 0
- ZOJ 1745 Are We There Yet?
- ZOJ 1745 Are We There Yet?
- zoj 1745 Are We There Yet?
- zoj 1745 Are We There Yet?
- Are We There Yet?
- zoj1745 Are We There Yet?
- fjnu 1298 Are We There Yet?
- Are We There Yet? (zoj1745)
- Couldn't get connection because we are at maximum connection count (150/150) and there are none 异常解决
- Couldn't get connection because we are at maximum connection count (50/50) and there are none av
- apple ——we are - are we
- English---There is / There are
- We Are The World
- We are approaching graduation
- Are we ready?
- So Here We Are
- We are a team!!!
- we are on grails
- 每日一题20:与C++11的第一次邂逅——可变参模板与C#委托模拟
- FlatUI风格的qml控件
- test
- cocos2dx2.x批量移除CCNode的方法
- 如何更好地给同事讲代码?
- zoj 1745 Are We There Yet?
- Ubuntu安装Oracle InstantClient
- Tracking Learning Detecting-TLD 学习笔记1
- SSH三大框架搭建的步骤
- Word Ladder II Java
- Hibernate映射的关系问题
- Android Hal层简要分析
- 读书无用论,学历无用论,以及其他
- SSH三大框架整合原理