Advertisement
SeriousVenom

Untitled

Feb 10th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include "pch.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.         int j = mass[i - 1];
  26.         mass[i - 1] = mass[i];
  27.         mass[i] = j;
  28.    
  29. }
  30.     cout << endl;
  31.  
  32.     cout << "New mass: " << endl;
  33.     for (int i = 0; i < N; i++)
  34.     {
  35.         cout << mass[i] << " ";
  36.  
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement