printing in column c 2b 2b

Solutions on MaxInterview for printing in column c 2b 2b by the best coders in the world

showing results for - "printing in column c 2b 2b"
Timeo
08 Jan 2020
1#include <iostream>
2#include <iomanip>
3#include <string>
4
5int main()
6{
7   std::string arr[]={"2","1","3","16","8","3","4","1","2"};
8   const int arrlength = sizeof(arr)/sizeof(*arr);
9   const int matrixSize = 3;
10
11   for(int row = 0; row < matrixSize; ++row)
12   {
13      for (int index = row; index < arrlength ; index += matrixSize)
14         std::cout << arr[index] << std::setw(5);
15      std::cout << "\n";
16   }
17
18  return 0;
19}
20