Advertisement
Jambix64

Deleta account

Jan 11th, 2019
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. //By Saraiva
  5. //Code delete list is add previous in next pos
  6. int main(){
  7.     int client[] = {1,2,3,4,6};
  8.     int numDelete = 3;
  9.     int size;
  10.     int sizeNew;
  11.     int lastPos = 0;
  12.     int ax[] = {};
  13.     size = sizeof(client) / sizeof(int);
  14.     for(int i = 0; i<size; i++ ){printf("Client Registereds: %d \n", client[i]);}
  15.     printf("\n");
  16.     printf("#### Engine #### \n \n");
  17.     for(int j = 0; j<size; j++ ){
  18.        if(numDelete == client[j]) {
  19.           lastPos = size;
  20.           ax[j] = client[j + 1]; // add[2 = 4];
  21.           for(int k = j + 1; k < size ; k++ )
  22.           {
  23.              //printf("Value %d \n",k);
  24.              if(k + 1 > lastPos) break; // If next position is major that new index finish
  25.              ax[k] = client[k + 1];  // add[3 = 6];
  26.            }
  27.         }
  28.         ax[j] = client[j]; // add[0 = 1,1 = 2];
  29.       }
  30.     for(int k = 0; k < 4; k++ ) {printf("Resultado: %d \n", ax[k]);}
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement