fuck this shit
This commit is contained in:
parent
6189cf6a3b
commit
5ebb6a96cc
@ -86,13 +86,18 @@ DiskRequest* findClosest(DiskQueue *queue, int position, double time) {
|
|||||||
if (closest == NULL) {
|
if (closest == NULL) {
|
||||||
closest = current;
|
closest = current;
|
||||||
} else {
|
} else {
|
||||||
if (abs(current->position - position) < abs(closest->position - position)) {
|
int closestDistance = closest->position - position;
|
||||||
|
int currentDistance = current->position - position;
|
||||||
|
if (currentDistance > 0) {
|
||||||
|
if (currentDistance < closestDistance) {
|
||||||
closest = current;
|
closest = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
// Bad
|
||||||
if (closest == NULL) {
|
if (closest == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,8 @@ int main(int argc, char **argv) {
|
|||||||
int start = 0;
|
int start = 0;
|
||||||
|
|
||||||
queue = createDiskQueue();
|
queue = createDiskQueue();
|
||||||
|
|
||||||
while (EOF != (scanf("%i %i\n", &position, &time))) {
|
while (EOF != (scanf("%i %i\n", &position, &time))) {
|
||||||
enqueue(queue, time, position);
|
enqueue(queue, time, position);
|
||||||
// printf("Delete me: position %i, Delete me: time %i\n", position, time);
|
|
||||||
}
|
}
|
||||||
if (algorithm == 'F') {
|
if (algorithm == 'F') {
|
||||||
fcfs(start);
|
fcfs(start);
|
||||||
|
Loading…
Reference in New Issue
Block a user