Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int sortowanie(int tab[] ,int lenght)
  4. {
  5. int i, j, pom;
  6. for(i=1;i<lenght;++i){
  7. pom = tab[i];
  8. for(j=i-1;j>=0 && tab[j] > pom;--j){
  9. tab[j+1]=tab[j];
  10. }
  11. tab[j+1]=pom;
  12. }
  13.  
  14. for(i=0;i<lenght;i++){
  15. printf("%d ", tab[i]);
  16. }
  17. return 0;
  18. }
  19. main()
  20. {
  21. int b;
  22. int a[b],c,d;
  23. printf("podaj dlugosc tablicy:\n");
  24. scanf("%d", &b);
  25. for(c=0; c<b;c++){
  26. printf("podaj liczbe");
  27. scanf("%d", &a[c]);
  28. }
  29. d=sortowanie(a,b);
  30. printf("%d", d);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement