Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fstream>
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "Rus");
- ifstream file("J:\\Универ\\Программирование\\Практика_txt\\z_2.txt");
- if (file.is_open())
- {
- cout << "Файл открыт" << endl;
- const int n = 30;
- int zero = 0, p = 0, m = 0;
- int F[n], A[n], D[n];
- cout << "Массив F:" << endl;
- for (int i = 0; i < n; i++)
- {
- file >> F[i];
- cout << "F[" << i << "] = " << F[i] << endl;
- if (F[i] == 0) zero++;
- if (F[i] < 0)
- {
- A[m] = F[i];
- m++;
- }
- if (F[i] > 0)
- {
- D[p] = F[i];
- p++;
- }
- }
- cout << "Массив отрицательных чисел: ";
- for (int i = 0; i < m; i++)
- {
- cout << A[i]<<" | ";
- }
- cout << endl << "Массив положительных чисел: ";
- for (int i = 0; i < p; i++)
- {
- cout << D[i] << " | ";
- }
- cout << endl << "Количество нулей: " << zero << endl;
- system("pause");
- return 0;
- }
- else
- {
- cout << "Файл не открыт" << endl;
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement