Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. main()
  4. {
  5. int N=5;
  6. int p;
  7. int t[N];
  8.  
  9. for(int i=0; i<N; i++)
  10. {
  11. cout << "wprowadz liczbe nr " << i+1 << ":" << endl;
  12. cin >> t[i];
  13. }
  14.  
  15. for(int i=0; i<N; i++)
  16. {
  17. cout << t[i] << " ";
  18. }
  19.  
  20. cout << "sortujemy: " << endl;
  21. for(int i=0; i<N-1; i++)
  22. {
  23. if( t[i+1] > t[i] )
  24. {
  25. p = t[i];
  26. t[i] = t[i+1];
  27. t[i+1]=p;
  28. }
  29. }
  30.  
  31. cout << endl;
  32.  
  33. for(int i=0; i<N; i++)
  34. {
  35. cout << t[i] << " ";
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement