Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
714 B
17
Indexable
#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;


int main() {
	srand((int)time(NULL));
	try
	{
		fstream file{ "input.txt",ios::in };
		string inp;
		vector<string>names;
		while (getline(file, inp))
		{
			names.push_back(inp);
		}
		file.close();
		for (int i = 0; i < names.size(); i++)
		{
			swap(names[i], names[rand() % names.size()]);
		}
		file.open("output.txt", ios::out);
		short n = 1;
		for (const auto& i : names)
		{
			if (n == 6)
			{
				n = 1;
				file << endl;
			}
			file << n << ") " << i << endl;
			n++;
		}
		file.close();
	}
	catch (const std::exception&e)
	{
		cout << e.what() << endl;
	}
}