Advertisement
Norbysweg

3

Nov 11th, 2021
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 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]<a[i])
  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.     return;
  22. }
  23. int main()
  24. {
  25.     int a[10000],i=0;
  26.     ifstream fin("DATE.TXT");
  27.     while(fin.eof()==0)
  28.     {
  29.         fin>>a[i];
  30.         i++;
  31.     }
  32.     fin.close();
  33.     ofstream fout("OUT.TXT");
  34.     buborek(a,i);
  35.     for(int j=0;j<i;j++)
  36.         fout<<a[j]<<" ";
  37.     fout.close();
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement