printing in column c++
#include <iostream>
#include <iomanip>
#include <string>
int main()
{
std::string arr[]={"2","1","3","16","8","3","4","1","2"};
const int arrlength = sizeof(arr)/sizeof(*arr);
const int matrixSize = 3;
for(int row = 0; row < matrixSize; ++row)
{
for (int index = row; index < arrlength ; index += matrixSize)
std::cout << arr[index] << std::setw(5);
std::cout << "\n";
}
return 0;
}