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) {
|
||||
closest = current;
|
||||
} else {
|
||||
if (abs(current->position - position) < abs(closest->position - position)) {
|
||||
closest = current;
|
||||
int closestDistance = closest->position - position;
|
||||
int currentDistance = current->position - position;
|
||||
if (currentDistance > 0) {
|
||||
if (currentDistance < closestDistance) {
|
||||
closest = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
// Bad
|
||||
if (closest == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -68,10 +68,8 @@ int main(int argc, char **argv) {
|
||||
int start = 0;
|
||||
|
||||
queue = createDiskQueue();
|
||||
|
||||
while (EOF != (scanf("%i %i\n", &position, &time))) {
|
||||
enqueue(queue, time, position);
|
||||
// printf("Delete me: position %i, Delete me: time %i\n", position, time);
|
||||
}
|
||||
if (algorithm == 'F') {
|
||||
fcfs(start);
|
||||
|
Loading…
Reference in New Issue
Block a user