Advertisement
Norbysweg

4

Nov 11th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. void buborek(int a[], int n)
  5. {
  6. bool f=1;
  7. while(f)
  8. {
  9. f=0;
  10. for(int i=0;i<n-1;i++)
  11. {
  12. if(a[i+1]%10<a[i]%10)
  13. {
  14. a[i+1]=a[i+1]+a[i];
  15. a[i]=a[i+1]-a[i];
  16. a[i+1]=a[i+1]-a[i];
  17. f=1;
  18. }
  19. }
  20. }
  21.  
  22. }
  23. int main()
  24. {
  25. int n,a[10001];
  26. ifstream fin("DATE.TXT");
  27. fin>>n;
  28. for(int i=0;i<n;i++)
  29. {
  30. fin>>a[i];
  31. }
  32. fin.close();
  33. buborek(a,n);
  34. for(int i=0;i<n;i++)
  35. cout<<a[i]<<" ";
  36.  
  37. return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement