Created
January 1, 2020 19:29
-
-
Save danielgospodinow/b3226e5cd416af7f55a52d8d68ff204c to your computer and use it in GitHub Desktop.
First task from the first DSP exam 2019/2020 (81786)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void fillgaps(node<int>* l) { | |
if(l == nullptr) { | |
return; | |
} | |
node<int>* current = l; | |
while (current->next != NULL) | |
{ | |
if (current->data != (current->next->data - 1)) | |
{ | |
node<int>* neww = new node<int>(); | |
neww->data = current->data + 1; | |
neww->next = current->next; | |
current->next = neww; | |
} | |
current = current->next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment