Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fstream>
- #include <iostream>
- using namespace std;
- void fill_in(int *a, int N, ifstream &file)
- {
- for (int i = 0; i < N; i++)
- {
- file >> a[i];
- cout << "F[" << i << "] = " << a[i] << endl;
- }
- }
- void simillar_iF(int *a, int N)
- {
- for (int i = 0; i < N; i++)
- {
- if (i == a[i]) cout << "F[" << i << "] = " << a[i] << endl;;
- }
- }
- int main()
- {
- setlocale(0, "Rus");
- ifstream file("J:\\Универ\\Программирование\\Практика_txt\\z_5.txt");
- if (file.is_open())
- {
- cout << "Файл открыт" << endl;
- const int N = 100;
- int F[N];
- cout << "Массив F: " << endl;
- fill_in(F, N, file);
- cout << endl << "Элементы, совпадающие с индексами: ";
- simillar_iF(F, N);
- system("pause");
- return 0;
- }
- else
- {
- cout << "Файл не открыт" << endl;
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement