Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fstream>
- #include <iostream>
- #include <vector>
- #include <string>
- int main()
- {
- std::ifstream File("F:/Folder/input.vgp", std::ifstream::in | std::ifstream::binary);
- std::ofstream OutFile("F:/Folder/output.txt");
- unsigned int SizeRead = 0;
- while (1)
- {
- if (File.is_open())
- {
- std::vector<int> AverageResults;
- int ResultsCount;
- File.seekg(0, std::ios::end);
- unsigned int Size = File.tellg();
- File.seekg(SizeRead, std::ios::beg);
- if (SizeRead < Size)
- {
- File.read((char*)& ResultsCount, sizeof(int));
- int Amount = 0;
- for (int ResultIndex = 1; ResultIndex <= ResultsCount; ResultIndex++)
- {
- int ResultValue = 0;
- File.read((char*)& ResultValue, sizeof(int));
- Amount += ResultValue;
- }
- AverageResults.push_back(Amount / ResultsCount);
- }
- SizeRead = File.tellg();
- OutFile.open("F:/Folder/output.txt", std::ofstream::end);
- if (OutFile.is_open())
- {
- for (int i = 0; i < AverageResults.size(); i++)
- {
- std::string str = std::to_string(AverageResults[i]);
- str += "\n";
- OutFile << str;
- }
- OutFile.close();
- }
- }
- else
- {
- File.open("F:/Folder/input.vgp", std::ifstream::in | std ::ifstream::binary);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement