POINT IN CIRCLE 题解
2013-12-27 12:18
260 查看
这一题更简单了,求点是否在圆上,直接看离圆心的距离是否等于半径即可
#include <iostream> #include <fstream> #include <string> using namespace std; int main (int argc, char* argv[]) { ifstream file; string lineBuffer; file.open(argv[1]); while (!file.eof()) { getline(file, lineBuffer); if (lineBuffer.length() == 0) continue; //ignore all empty lines else { double centerX, centerY, radius, pointX, pointY; double x, y; sscanf(lineBuffer.c_str(), "Center: (%lf, %lf); Radius: %lf; Point: (%lf, %lf)", ¢erX, ¢erY, &radius, &pointX, &pointY); x = pointX - centerX; y = pointY - centerY; if(x*x + y*y - radius*radius < 0.01) cout << "true" << endl; else cout << "false" << endl; } } return 0; }
相关文章推荐
- Chapter_03 分析C语言的声明
- jsp+servlet+commons-fileupload-1.3.jar+commons-io-2.4.jar+jstl标签库实现文件上传与下载
- python 调用 shell python shell 间变量传递
- 嵌入式QT的编译
- jedis基本介绍(2)
- APMServ5.2.6 升级PHP版本 到高版本 5.3,5.4
- CASUAL_NCT
- 读书笔记---《理解Unix进程》
- python按行读取文件 去掉换行符"\n"
- 虚表/虚指针
- 小明的难题
- MINIMUM COINS题解 codeEval
- Tomcat基础教程(四)
- 小明求素数积
- Tomcat基础教程(三)
- 感悟人生
- $_FILES文件类型
- DHCP学习(二),拆分作用域
- Hadoop学习常用的Linux命令
- 从java 转到 c# 知识点