Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- //By Saraiva
- //Code delete list is add previous in next pos
- int main(){
- int client[] = {1,2,3,4,6};
- int numDelete = 3;
- int size;
- int sizeNew;
- int lastPos = 0;
- int ax[] = {};
- size = sizeof(client) / sizeof(int);
- for(int i = 0; i<size; i++ ){printf("Client Registereds: %d \n", client[i]);}
- printf("\n");
- printf("#### Engine #### \n \n");
- for(int j = 0; j<size; j++ ){
- if(numDelete == client[j]) {
- lastPos = size;
- ax[j] = client[j + 1]; // add[2 = 4];
- for(int k = j + 1; k < size ; k++ )
- {
- //printf("Value %d \n",k);
- if(k + 1 > lastPos) break; // If next position is major that new index finish
- ax[k] = client[k + 1]; // add[3 = 6];
- }
- }
- ax[j] = client[j]; // add[0 = 1,1 = 2];
- }
- for(int k = 0; k < 4; k++ ) {printf("Resultado: %d \n", ax[k]);}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement