fuck this shit
This commit is contained in:
		| @@ -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)) { | ||||
| 				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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user