SkeptaProgrammer

Untitled

Jun 25th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <fstream>
  4. #include <ctime>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     ofstream file("1.txt");
  11.     int digit = 0, k = -1, n, cou = 0;
  12.     cout << "кол-во чисел\n"; cin >> n;
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         cin >> digit;
  16.         file << digit;
  17.         file << " ";
  18.         if (digit % 2 != 0) cou++;
  19.     }
  20.     int *odd = new int[cou];
  21.     file.close();
  22.     ifstream file1("1.txt");
  23.     for (int i = 0; i < n; i++)
  24.     {
  25.  
  26.         file1 >> digit;
  27.         if (digit % 2 != 0)
  28.         {
  29.             k++;
  30.             odd[k] = digit*2;
  31.         }
  32.     }
  33.     for (int i = 0; i < cou; i++)
  34.     {
  35.         cout << odd[i];
  36.     }
  37.     file1.close();
  38.  
  39.     delete[] odd;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment