Creando archivos "transpuestos" con caracteres aleatorios

Quiero crear un programa que cree archivos ".txt" con caracteres aleatorios, pero con la posibilidad de crear "archivos" transpuestos. A continuación, agrego un ejemplo de dos archivos ".txt" como pretendo hacer.

FILE1

A|B|C|D|E|F|G|

H|I|J|K|L|M|N|

O|P|Q|R|S|T|U|

V|W|Z|1|2|3|4|

ARCHIVO2 (ARCHIVO1 transpuesto)

A|H|O|V|

B|I|P|W|

C|J|Q|Z|

D|K|R|1|

E|L|S|2|

F|M|T|3|

G|N|U|4|

Y ahora agrego el código que he escrito para que pueda echar un vistazo y darme algunas ideas sobre cómo hacerlo, qué modificar, et

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<ctime>

using namespace std;

int main()
{
    int rows, columns, element1;

    char word[10];

    ofstream myfile ("File 1.txt");
    if(myfile)
        srand(1);
    for(rows=0;rows<10;rows++)
    {
        for(columns=0;columns<30;columns++)
        {
            element1 = rand() % 100000 + 1;
            int len = rand () % 4 + 4;
            word [len] = 0;
            while (len) word [--len] = 'A' + rand () % 58;

            myfile<<element1<<word;
            myfile<<"|";
        }
        myfile<<endl;

    }
    myfile.close();


    ofstream myfileS ("File 2.txt");
    if(myfileS)
        srand(1);
    for(columns=0;columns<30;columns++)
    {
        for(rows=0;rows<10;rows++)
        {

            element1 = rand() % 100000 + 1;
            int len = rand () % 4 + 4;
            word [len] = 0;
            while (len) word [--len] = 'A' + rand () % 58;

            myfileS<<element1<<word;
            myfileS<<"|";
        }
        myfileS<<endl;
    }
    myfile.close();



    system("pause");
    return 0;

}

¡Gracias por tu ayuda

SOLUCIÓN DE MI DUDA

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<ctime>
#include<sstream>

using namespace std;

int main()
{
int rows, columns, rowsMax, columnsMax; 
int element1;

    char word[10];

int a=0;

cout<<"Write the number of rows of your table: ";
cin>>rowsMax;

cout<<"Write the number of columns of your table: ";
cin>>columnsMax;

int answer;
cout<<"Do you want to create the transposed table??? (1 -> yes, 2 -> no): ";
cin>>answer;

string matriz[7][5]; // string matriz[rowsMax][columnsMax]; I should modify this in every query

string table ("Table1.txt");
ofstream myfile (table);
if(myfile.is_open())
srand(1);
myfile<<id<<"|"<<type<<"|"<<columnsMax<<endl;
for(rows=0;rows<rowsMax;rows++)
{
    for(columns=0;columns<columnsMax;columns++)
    {
        element1 = rand() % 100000 + 1;
        int len = rand () % 4 + 4;
        word [len] = 0;
        while (len) word [--len] = 'A' + rand () % 58;
        myfile<<element1<<word;
        myfile<<"|";

        std::stringstream ss;
            ss<<element1;

        string mat;
        mat +=ss.str();
        mat +=word;
        matriz[rows][columns]= mat;
    }
    myfile<<endl;

}
myfile.close();


while(answer==1)
{
    string table ("Table");
    table +=id;
    table +="(transposed)";
    table +=".txt";
    ofstream myfile (table);
    if(myfile.is_open())
    myfile<<id<<"|2|"<<columnsMax<<endl;
    for(int k=0;k<5;k++)
    {
            for(int j=0;j<7;j++)
        {
            myfile<<matriz[j][k]<<"|";
        }
            myfile<<endl;
    }
    answer=2;
}
system("pause");
return 0;

}

Respuestas a la pregunta(1)

Su respuesta a la pregunta