Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <windows.h>
  4. #include <stdlib.h>
  5. using namespace std;
  6.  
  7. int mas[100000];
  8.  
  9. int main(){
  10. int n=8;
  11. for (int i=0; i<n;i++){
  12. cin>>mas[i];
  13. }
  14. cout<<"\nStart data: a[1] = "<< mas[1]<<"\n";
  15. cout<<"a["<<n-1<<"]="<<mas[n-1];
  16. double t1=clock();
  17. for(int i=1; i<n; i++){
  18. int key = mas[i];
  19. int j=i=1;
  20. while((j>-1)&(key>mas[j])){
  21. mas[j+1]=mas[j];
  22. j=j-1;
  23. }
  24. mas[j+1]=key;
  25. }
  26. double t2=clock();
  27. cout<<"Time:"<<(t2-t1)/CLOCKS_PER_SEC<<"\n";
  28. cout<<"a[1]="<<mas[1]<<"\n";
  29. cout<<"a["<<n-1 << "]="<<mas[n-1]<<"\n";
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement