SHARE
TWEET

Problema 1

a guest Mar 26th, 2019 67 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 n,v[20000],i,j,c,k;
  5. int main()
  6. {
  7.     ifstream f("date.in");
  8.     ofstream g("date.out");
  9.     while(f>>v[k])
  10.     {
  11.         k++;
  12.     }
  13.     for(i=0; i<k; i++)
  14.         for(j=0; j<k; j++)
  15.             if(i%2==0 && j%2==0 && v[i]<v[j])
  16.             {
  17.                 c=v[i];
  18.                 v[i]=v[j];
  19.                 v[j]=c;
  20.             }
  21.             else if(i%2!=0 && j%2!=0 && v[i]>v[j])
  22.             {
  23.                 c=v[i];
  24.                 v[i]=v[j];
  25.                 v[j]=c;
  26.             }
  27.     for(i=0; i<k; i++)
  28.         g<<v[i]<<endl;
  29.  
  30. }
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