2001
2016-03-27 13:40
218 查看
计算2点之间的距离
参考c++
#include <stdio.h> #include <math.h> int mydistance(int a,int b,int c,int d); int main() { char buff[8]; int buffer[4]; while(gets(buff)) { buffer[0] = buff[0] - '0'; buffer[1] = buff[2] - '0'; buffer[2] = buff[4] - '0'; buffer[3] = buff[6] - '0'; printf("%d\n",mydistance(buffer[0],buffer[1],buffer[2],buffer[3])); } return 0; } int mydistance(int a,int b,int c,int d) { int e; e = sqrt((c - a)*(c - a) + (d - b)*(d - b)); return e; }
参考c++
#include <cmath> #include <cstdio> int main(void) { double x[2], y[2]; while (scanf("%lf%lf%lf%lf", x, y, x+1, y+1) != EOF) printf("%.2f\n", sqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]))); return 0; }
相关文章推荐
- 今日BBC
- android用符号表定位问题
- BZOJ_P1492 [NOI2007]货币兑换Cash(CDQ分治+斜率优化)
- JMeter之基本概念-The Test Plan
- 快速存档表数据
- usb总线系统介绍
- 在mac上用AndroidStudio1.5 创建NDK开发环境
- PreferenceActivity点击事件?
- 终结任务
- tomcat部署java servlet的3种方式
- C++11智能指针之使用shared_ptr实现多态
- 5.Utm线程模型
- Linux系统启动流程简介
- 使用Docker在Ubuntu下安装Skype报错
- Java中Linked中push(),pop()方法
- unity所有特殊文件夹的用途
- android与其他应用的交互
- 第20课 链接过程简介
- 第五周项目1-三角形类雏形(3)
- HTTPS原理