it works well in VC++ 6.0
[cpp]
#include <stdio.h>
#include <iostream.h>
#include <math.h>
#include <string.h>
double hypot(double x, double y)
{
return sqrt(x*x + y*y);
}
int main() {
int mins, p;
double x, y, xx, yy;
double dist = 0;
char line[80], s[80], temp[80], *ss;
int kase;
cin >> kase;
while (kase--) {
cin >> x >> y;
cin.getline(line, 80, '\n');
cin.getline(line, 80, '\n');
while (line[0] >= '0') {
p = strchr(line, ' ') - line + 1;
strncpy(s, line, p - 1);
x = atof(s);
ss = &line[p];
strcpy(temp, ss);
strcpy(line, temp);
p = strchr(line, ' ') - line + 1;
strncpy(s, line, p - 1);
y = atof(s);
ss = &line[p];
strcpy(temp, ss);
strcpy(line, temp);
p = strchr(line, ' ') - line + 1;
strncpy(s, line, p - 1);
xx = atof(s);
ss = &line[p];
strcpy(temp, ss);
strcpy(line, temp);
yy = atof(line);
dist += hypot( xx-x, yy-y );
cin.getline(line, 80, '\n');
}
dist /= 10000.0;
mins = (int)(dist * 60.0 + 0.5);
printf("%lf:%02lf\n", mins/60, mins%60);
if (kase) printf("\n");
}
return 0;
}
[/cpp][/c]
why does this code got Compilation Error
Moderator: Board moderators
-
- New poster
- Posts: 27
- Joined: Wed Apr 17, 2002 7:54 pm