Advertisement
FR4GG13

sortowanie przez bisekcję (beta)

Mar 4th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int i,n;
  7. printf("podaj ilosc elementow tablicy:\n");
  8. scanf("%d",&n);
  9.  
  10. int tab[n],s,sr,l,p,srch;
  11. printf("podaj poszczegolne elementy:\n");
  12.  
  13. for(i=0;i<n;i++){
  14. scanf("%d",&tab[i]);
  15. }
  16.  
  17. printf("podaj szukana wartosc:\n");
  18. scanf("%d",&s);
  19.  
  20. for(l=0;l<n;l++){
  21. p=n-1;
  22. sr=(l+p)/2;
  23. if(tab[sr]<s)
  24. l=sr;
  25. else if(tab[sr]>s)
  26. p=sr;
  27. else
  28.  
  29.  
  30.  
  31.  
  32. }
  33.  
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement