Guest User

Untitled

a guest
Nov 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. #define SIZE 12
  4.  
  5. int main() {
  6.  
  7. int arr[SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  8.  
  9. int size = SIZE;
  10. int i = 0;
  11. int pos = 4;
  12. int sz = size - 1;
  13. int i_next = 0;
  14.  
  15. // show defaulp array
  16. for (i = 0; i < size; i++)
  17. printf("%d\t", arr[i]);
  18.  
  19. printf("\n\n");
  20.  
  21.  
  22.  
  23. for (i = pos - 1; i < sz; i++) {
  24. i_next = i + 1;
  25. printf("i = %d\n", i);
  26. arr[i] = arr[i_next];
  27. }
  28.  
  29. printf("\n\n");
  30.  
  31. // update the size
  32. size--;
  33.  
  34. // print new array
  35. for (i = 0; i < size; i++)
  36. printf("%d\t", arr[i]);
  37.  
  38. printf("\n");
  39.  
  40. return 0;
  41. }
Add Comment
Please, Sign In to add comment