#include <iostream>
#include <string>
int main() {
using std::cin;
using std::cout;
using Person = std::string;
constexprint N = 4;
Person p1[ N*N ];
cout << "Enter the name of subject\n";
for ( int i=0; i < N*N; ++i ) {
cin >> p1[i];
}
for ( int row=0; row < N; ++row ) {
for ( int col=0; col < N; ++col ) {
cout << p1[ row*N + col ] << '\t';
}
cout<<'\n';
}
return 0;
}
To use vector, replace line 10 with std::vector<Person> p1( N*N );
and the N*N on line 13 with p1.size()