fuck this shit

This commit is contained in:
Isaac Shoebottom 2023-11-28 21:31:01 -04:00
parent 6189cf6a3b
commit 5ebb6a96cc
2 changed files with 7 additions and 4 deletions

View File

@ -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;
closest = current; int currentDistance = current->position - position;
if (currentDistance > 0) {
if (currentDistance < closestDistance) {
closest = current;
}
} }
} }
} }
current = current->next; current = current->next;
} }
// Bad
if (closest == NULL) { if (closest == NULL) {
return NULL; return NULL;
} }

View File

@ -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);