C++ 片段
来源:互联网 发布:sql语句修改表结构 编辑:程序博客网 时间:2024/05/25 23:28
</pre><pre code_snippet_id="1563821" snippet_file_name="blog_20160124_1_1082829" name="code" class="cpp">#include <iostream>#include "opencv2/highgui/highgui.hpp"#include "opencv2/imgproc/imgproc.hpp"#include <string>#include <stdio.h>#include <map>#define pi 3.141592654using namespace std;using namespace cv;vector <Point> arr;vector <double> angle;Point scal;int n = 0; void create(){int x, y;while (cin >> x >>y){scal.x = x;scal.y = y;arr.push_back(scal);}for (vector<Point>::iterator it = arr.begin(); it != arr.end(); it++)cout << *it << endl;}void cal_angle(){ map<double, size_t> scalnum;for (int n = 0; n < arr.size(); n++) angle.push_back(180*atan(arr[n].y/arr[n].x)/pi);sort(angle.begin(), angle.end());for (vector<double>::iterator it = angle.begin(); it != angle.end(); it++){cout << *it << endl;scalnum[*it] = n;n++;}for (const auto &s : scalnum){cout << s.first << " is " << s.second << endl;}}int main(){ create();cal_angle();return 0;}
在计算坐标的时候,需要算出角度,以上是个实现的简单例子。
0 0
- c语言片段一
- <c:forEach>详解+代码片段
- 牛客网DNA片段C/C++
- 片段
- 片段
- 片段
- 片段
- 高质量C/C++编程(片段)
- TreeView(C#)无限目录树代码片段
- C语言不错的代码片段
- Java 删除c/c++/java代码注释的代码片段
- 一个滤掉C/C++风格的注释的片段
- 与Pocket Outlook相关的一些代码片段(C#)
- objective-c中的一些小代码片段记录
- Objective C 常用代码片段制作(code snippet library)
- C语言(第一个程序片段的分析)
- NET(C#):使用HttpWebRequest头中的Range下载文件片段
- [libxml2]_[C/C++]_[使用libxml2读取内存的xml片段]
- Hdu1241Oil Deposits
- 最全常用正则表达式列表
- 对View绘制流程的一些理解
- Codeforces Round #340 (Div. 2)-A. Elephant(贪心)
- 2014年第五届蓝桥杯B组(C/C++)预赛题目及个人答案(欢迎指正)
- C++ 片段
- 跨浏览器兼容性总结
- 【PHP进阶篇 未完】5.正则表达式--慕课网【学习总结】
- Codeforces Round #340 (Div. 2)——D
- C++ primer P81 练习3.5
- 2015年第六届蓝桥杯C/C++程序设计本科B组省赛 加法变乘法(结果填空)
- HDU 5612 Baby Ming and Matrix games(dfs搜索)
- Codeforces Round #340 (Div. 2)-B. Chocolate(组合数学的乘法计数)
- uva11300 - Spreading the Wealth (中位数)