Advertisement
GerexD

asdf

Dec 11th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. void beolvas(int a[],int &n)
  6. {
  7. ifstream f("bac.txt");
  8. f>>n;
  9. for(int i=1;i<=n;i++)
  10. f>>a[i];
  11. }
  12.  
  13. void csere(int &x,int &y)
  14. {
  15. int z=x;
  16. x=y;
  17. y=z;
  18. }
  19. void rendez(int a[],int n)
  20. {
  21. int jo;
  22. int nn=n;
  23. do
  24. {
  25. jo=1;
  26. for(int i=1;i<=nn-1;i++)
  27. if (a[i]>a[i+1])
  28. { csere(a[i],a[i+1]);
  29. jo=0;
  30. }
  31. nn--;
  32. } while (jo==0);
  33.  
  34. }
  35. void kiir(int a[],int n)
  36. {
  37. for(int i=1;i<=n;i++)
  38. cout<<a[i]<<" ";
  39. }
  40. int main()
  41. {
  42.  
  43. int a[20],n;
  44. beolvas(a,n);
  45. rendez(a,n);
  46. kiir(a,n);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement