Professional Documents
Culture Documents
Снітко Анна ІТУ-21-3 ПЗ 4 АПр
Снітко Анна ІТУ-21-3 ПЗ 4 АПр
Снітко Анна ІТУ-21-3 ПЗ 4 АПр
Кафедра системотехніки
ПРАКТИЧНЕ ЗАНЯТТЯ № 4
2021р.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <ctime>
#include <cmath>
int main()
setlocale(LC_ALL, "rus");
srand(time(0));
if (!stream1)
return 0;
fillFile(col, stream1);
read_files(stream1, stream2);
}
void fillFile(const int col, fstream& stream1, fstream& stream2) {
stream1.seekg(0);
stream1.read((char*)&val, sizeof(val));
if (val > 0)
stream2.write((char*)&val, sizeof(val));
stream1.seekg(0);
stream1.read((char*)&val, sizeof(val));
if (val == 0)
stream2.write((char*)&val, sizeof(val));
stream1.seekg(0);
stream1.read((char*)&val, sizeof(val));
if (val < 0)
stream2.write((char*)&val, sizeof(val));
stream.write((char*)&val, sizeof(val));
}
void read_files(fstream& stream1, fstream& stream2)
stream1.clear();
stream1.seekg(0);
int valRead1;
stream1.read((char*)&valRead1, sizeof(int));
stream2.clear();
stream2.seekg(0);
int valRead2;
stream2.read((char*)&valRead2, sizeof(int));