📜  在列 c++ 代码示例中打印

📅  最后修改于: 2022-03-11 14:44:53.919000             🧑  作者: Mango

代码示例1
#include 
#include 
#include 

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;
}