Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main() {
  4. int size = -1;
  5. printf("Enter the size of array : ");
  6. scanf("%d" , &size);
  7. int initialArray[size];
  8. printf("Enter the array :\n");
  9. for(int i = 0 ; i < size ; i++) {
  10. scanf("%d" , &initialArray[i]);
  11. }
  12.  
  13. int helpArraySize = size%2==0 ? size/2 : size/2 + 1;
  14. int helpArray[helpArraySize];
  15.  
  16.  
  17. printf("Help Array : \n");
  18. for(int i = 0 ; i <helpArraySize; i++){
  19. helpArray[i] = initialArray[i*2];
  20. printf(" %d" , helpArray[i]);
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement