Advertisement
Lisaveta777

?Done with 2nd array

Nov 10th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define SIZE 9
  4.  
  5. //DONE WITH SECONDD ARRAY! NOT ELEGANT AT ALL
  6.  
  7. void pop_arr(int s,int *a);
  8. void small_big_arr(int s,int *a);
  9.  
  10. int main()
  11. {
  12.     int arr[SIZE]= {0,1,2,3,4,5,6,7,8};
  13.     int arr2[SIZE];
  14.     //pr_arr(SIZE,arr);
  15.     sort_arr(SIZE,arr,arr2);
  16.     pr_arr(SIZE,arr2);
  17.  
  18.     return 0;
  19.  
  20. }
  21. void pop_arr(int s,int *a)
  22. {
  23.     int i,j;
  24.     for(i=0;i<s;i++)
  25.     {
  26.             a[i]= rand()%10;
  27.  
  28.     }
  29. }
  30. void pr_arr(int s,int *a)
  31. {
  32.     int i,j;
  33.     for(i=0;i<s;i++)
  34.     {
  35.         printf("%d\t",a[i]);
  36.  
  37.     }
  38.     printf("\n\n");
  39. }
  40. void sort_arr(int s,int *a,int *a2)
  41. {
  42.     int i,j;
  43.     for(i=0;i<s;i++)
  44.     {
  45.         a2[i]= (i<s/2)? a[s-2*(i+1)]: a[2*(i-s/2)];
  46.         //a2[i]= (i<s/2)? a[s-2*i-2]: a[(i-s/2)*2];
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement