#include <iostream>
#include <fstream>
#include <string>

int main()
{
	std::string filename("file.txt");
	std::ofstream ofs;
	ofs.open(filename, std::ios::binary);
	const int n = 4, array_size = 3, half = n * array_size;
	
	for (int i = 0; i < n; ++i)
	{
		const int position = ofs.tellp();
		ofs.write((n % 2 == 0) ? "abc" : "XYZ", array_size);
		ofs.seekp(position + half);
		ofs.write((n % 2 == 0) ? "ABC" : "xyz", array_size);
		ofs.seekp(position + array_size);
	}
	
	ofs.close();
	std::cin.get();
	return 0;
}