1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <stdio.h>
int
main(void)
{
float latitude;
float longitude;
char info[80];
int started = 0;
puts("data=[");
while (scanf("%f,%f,%79[^\n]",&longitude, &latitude, info) == 3) {
if (started)
printf(",\n");
else
started = 1;
if (longitude < -180 || longitude > 180 ||
latitude < -90 || latitude > 90) {
fprintf(stderr, "Latitude must be between -90,90 and longitude -180,180\n");
return 2;
}
printf("{latitude: %f, longitude: %f, info: '%s'}",
latitude, longitude, info);
}
puts("\n]");
return 0;
}
|