• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 12th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <stdio.h>
2. #include <stdlib.h>
3. init_array(int A[n],int n);
4. print_array(int A[n]; int n);
5. swap(int A[t],int t);
6. shaker_sort(int A[n],n);
7. int main()
8. {
9.     const int n=10;
10.     int A[n];
11.     init_array(A[n],n);
12.     print_array(A[n],n);
13.     printf("\n");
14.     shaker_sort(A[n],n);
15.     print_array(A[n],n);
16. }
17.
18.     shaker_sort(int A[n],n)
19. {
20. int l_board=0;
21. int r_board=n-1;
22. while(l_board<r_board)
23. {
24. int k=0;
25. int j=1;
26. while(j<n)
27.
28. if(A[k]<A[k+1])
29. k=j;
30. j=j+1;
31. else
32. swap(A[k],k);
33. j=k;
34. k=k-1;
35. if(k=0)
36. k=j;
37. j=j+1;
38. }
39. }
40. init_array(int A[n],int n)
41. {
42. for(i=0;i<n;i++)
43.   {
44.    A[i]=rand()%101;
45.   }
46. }
47. print_array(int A[n]; int n)
48. {
49.     for(i=0;i<n;i++)
50.     {
51.         printf("%d",A[i]);
52.     }
53. }
54. swap(int A[t],int t)
55. {
56.     int temp = A[t-1];
57.     A[t-1]=A[t];
58.     A[t]=temp;
59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top