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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int colltype = -1;
int postype = -1;
int verbose = 0;
static int usage() {
printf(
"clld Version MFIYA.\n"
"Usage: clld [options]\n"
"Options:\n"
" -c<type> Force the collision type to be\n"
" the specified type (0-2).\n"
" -p<type> Force the position type to be\n"
" the specified type (0-2).\n"
" -v[level] Sets the verbosity level (0-3).\n"
);
return 0;
}
int main(int argc, char **argv) {
struct pos {
int x;
int y;
int z;
double fx;
double fy;
double fz;
};
struct pos cursor;
struct pos floor;
struct pos tmp;
char *buf = NULL;
size_t size;
getline(&buf, &size, stdin);
if (postype == -1)
postype = atoi(strtok(buf, "\n"));
buf = NULL;
getline(&buf, &size, stdin);
if (colltype == -1)
colltype = atoi(strtok(buf, "\n"));
printf("%i\n%i\n", postype, colltype);
for (int i = 0; i <= 1; i++) {
char *tmp2;
buf = NULL;
getline(&buf, &size, stdin);
if (strchr(buf, '.') != NULL) {
tmp.fx = atof(strtok(buf,","));
tmp.fy = atof(strtok(NULL,","));
tmp2 = strtok(NULL, "\n");
if (tmp2 == NULL)
tmp.fz = atof(strtok(NULL,"\0"));
else
tmp.fz = atof(tmp2);
if (!i) {
cursor = tmp;
printf ("%07.06f, %07.06f, %07.06f\n", cursor.fx, cursor.fy, cursor.fz);
} else {
floor = tmp;
printf ("%07.06f, %07.06f, %07.06f\n", floor.fx, floor.fy, floor.fz);
}
} else {
tmp.x = atoi(strtok(buf,","));
tmp.y = atoi(strtok(NULL,","));
tmp2 = strtok(NULL, "\n");
if (tmp2 == NULL)
tmp.z = atoi(strtok(NULL, "\0"));
else
tmp.z = atoi(tmp2);
if (!i) {
cursor = tmp;
printf ("%i, %i, %i\n", cursor.x, cursor.y, cursor.z);
} else {
floor = tmp;
printf ("%i, %i, %i\n", floor.x, floor.y, floor.z);
}
}
}
free(buf);
fflush(stdout);
return 0;
}
|