Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <ctime>
- #include <iomanip>
- using namespace std;
- int main()
- {
- ofstream file("1.txt");
- int digit = 0, k = -1, n, cou = 0;
- cout << "кол-во чисел\n"; cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> digit;
- file << digit;
- file << " ";
- if (digit % 2 != 0) cou++;
- }
- int *odd = new int[cou];
- file.close();
- ifstream file1("1.txt");
- for (int i = 0; i < n; i++)
- {
- file1 >> digit;
- if (digit % 2 != 0)
- {
- k++;
- odd[k] = digit*2;
- }
- }
- for (int i = 0; i < cou; i++)
- {
- cout << odd[i];
- }
- file1.close();
- delete[] odd;
- }
Advertisement
Add Comment
Please, Sign In to add comment