daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int A[20000],N;
  5. void Olvas()
  6. {
  7.  
  8.     ifstream f("sokszam.in");
  9.     f>>N;
  10.     for(int i=0;i<=N-1;i++)
  11.     {
  12.             f>>A[i];
  13.     }
  14.     f.close();
  15. }
  16. void Csere(int &a,int &b)
  17. {
  18.     int s=a;
  19.     a=b;
  20.     b=s;
  21. }
  22. void QuickSort(int e,int u)
  23. {
  24.     int elol=1,i=e,j=u;
  25.     while(i<j)
  26.     {
  27.         if (A[i]>A[j])
  28.         {
  29.             Csere(A[i],A[j]);
  30.             elol=1-elol;
  31.         }
  32.         if(elol)
  33.             j--;
  34.         else
  35.             j++;
  36.     }
  37.     if((i-e)>1)
  38.         QuickSort(e,i-1);
  39.     if((u-1)>1)
  40.         QuickSort(i+1,u);
  41. }
  42. void Kiir()
  43. {
  44.     ofstream g("sokszam.out");
  45.     for(int i=0;i<=N-1;i++)
  46.         g<<A[i]<<" ";
  47.     g.close();
  48.  
  49. }
  50. int main()
  51. {
  52.     Olvas();
  53.     QuickSort(0,N-1);
  54.     Kiir();
  55.     return 0;
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top