Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int *wsk, *tablica, n;
  8.  
  9. int main()
  10. {
  11. cout <<"podaj wielkosc tablicy: ";
  12. cin >> n;
  13. tablica = new int[n];
  14. wsk = tablica;
  15. for(int i=0; i<n; i++)
  16. {
  17. cout << "podaj " << i+1 << " element tablicy: ";
  18. cin >> *wsk;
  19. wsk++;
  20. }
  21.  
  22. for(int i=0; i<n; i++)
  23. {
  24. int a, b;
  25. for(int i=0; i<n; i++)
  26. {
  27. a=tablica[i];
  28. b=tablica[i+1];
  29. if (a>b)
  30. {
  31. tablica[i+1]=a;
  32. tablica[i]=b;
  33. }
  34. }
  35. }
  36. wsk = tablica;
  37.  
  38. for(int i=0; i<n; i++)
  39. {
  40. cout << *wsk << endl;
  41. wsk++;
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement