#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double distance(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
double x0,y0;
double x1,x2,y1,y2;
char street[80];
while(scanf("%lf%lf\n",&x0,&y0)!=EOF)
{
double dist=0;
gets(street);
while(street[0]!='j')
{
sscanf(street,"%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
dist+=distance(x1,y1,x2,y2);
gets(street);
}
dist=60*2.0*dist/20000.0;
int spend=floor(dist+0.5);
printf("%d:%02d\n",spend/60,spend%60);
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double distance(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
double x0,y0;
double x1,x2,y1,y2;
char street[80];
while(scanf("%lf%lf\n",&x0,&y0)!=EOF)
{
double dist=0;
gets(street);
while(street[0]!='j')
{
sscanf(street,"%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
dist+=distance(x1,y1,x2,y2);
gets(street);
}
dist=60*2.0*dist/20000.0;
int spend=floor(dist+0.5);
printf("%d:%02d\n",spend/60,spend%60);
}
return 0;
}
本文提供了一个使用C++编程语言解决实际问题的实例:通过输入坐标点,计算两点间的距离,并根据距离换算成时间单位。程序通过循环读取多个坐标点对,最终输出总行驶时间,单位为分钟。
6324

被折叠的 条评论
为什么被折叠?



