Created
November 21, 2016 16:27
-
-
Save nahiyan/1cae871bbe07e0c53a1c0fd3065dc1bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
// 1 2 3 4 5 | |
// 1 3 4 5 -1 | |
void deleteItem (int list[], int z, int index) { | |
int i = index; | |
while (i < z) { | |
if ((i + 1) < z) // if there's an item on the left | |
list[i] = list[i + 1]; | |
else | |
list[i] = -1; | |
i++; | |
} | |
} | |
int main () { | |
int list[] = {1, 2, 3, 4, 5}, i; | |
deleteItem(list, 5, 1); | |
for (i = 0; i < 5; i++) { | |
printf("%d\n", list[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment