SHARE
TWEET

E3

a guest Feb 19th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     int N;
  12.     cout << "Enter integer values: ";
  13.     cin >> N;
  14.     int *mass = new int[N];
  15.     ifstream ff("text1.txt");
  16.     if (!ff)
  17.         return 0;
  18.     for (int i = 0; i < N; i++)
  19.     {
  20.         ff >> mass[i];
  21.         cout << mass[i] << " ";
  22.  
  23.     }
  24.     for (int i = 1; i < N; i += 2) {
  25.  
  26.         int j = mass[i - 1];
  27.         mass[i - 1] = mass[i];
  28.         mass[i] = j;
  29.  
  30.     }
  31.     cout << endl;
  32.  
  33.     cout << "New mass: " << endl;
  34.     for (int i = 0; i < N; i++)
  35.     {
  36.         cout << mass[i] << " ";
  37.  
  38.     }
  39.  
  40. }
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