#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
#include <algorithm>
int main()
{
std::fstream input("input.txt");
std::vector<short> vec; // значения из файла
std::copy(std::istream_iterator<int>(input), std::istream_iterator<int>(), std::back_inserter(vec));
std::copy(vec.begin(), vec.end(), std::ostream_iterator<int>(std::cout, " "));
std::ofstream fout("data.dat", std::ios::out | std::ios::binary);
const size_t columnCount = 6;
for (size_t i = 0; i < vec.size(); i+= columnCount)
{
int index = i / columnCount + 1;
fout.write((char *)&index, sizeof(int));
for (size_t j = 0; j < columnCount; j++)
{
fout.write((char*)&vec[i + j], sizeof(short));
}
}
fout.close();
return 0;
}