Browse Source

starter code

mbarsky 2 years ago
parent
commit
e6ee138051
2 changed files with 32 additions and 0 deletions
  1. 11 0
      bermuda.c
  2. 21 0
      geo2js.c

+ 11 - 0
bermuda.c

@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main() {
+	float latitude;
+	float longitude;
+	char info[80];
+	while (fscanf(stdin,"%f,%f,%79[^\n]", &latitude , &longitude , info ) == 3)
+		if (((latitude > 30) && (latitude < 33)) && ((longitude > -69) && (longitude < -66)))
+			printf("%f,%f,%s\n",latitude, longitude, info );
+		return 0;
+}

+ 21 - 0
geo2js.c

@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int main() {
+    float latitude;
+    float longitude;
+    char info[80];
+
+    int started = 0;
+    printf("var data=[\n");
+
+    while (scanf("%f,%f,%79[^\n]", &latitude , &longitude , info ) == 3) {
+        if (started)
+			printf(",\n");
+		else
+			started = 1;
+		printf("{latitude: %f, longitude: %f, info: '%s'}", latitude , longitude , info);
+        
+    }
+    printf("\n];\n");
+    return 0;
+}