Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: What is a ~ in c++ 
Cpp :: pop off end of string c++ 
Cpp :: initialize 2d vector c++ 
Cpp :: Initialize Vector Iterator Through Vector Using Iterators 
Cpp :: c++ json parser euc-kr 
Cpp :: C++ Arrays and Loops 
Cpp :: iterate const vector 
Cpp :: c++ while loop 
Cpp :: c++ random int troll 
Cpp :: prime number program c++ 
Cpp :: c++ stl vector get iterator from index 
Cpp :: iomanip header file in c++ 
Cpp :: int cpp 
Cpp :: clear map in C++ 
Cpp :: time complexity of sorting algorithms 
Cpp :: select elements from array C++ 
Cpp :: dangling pointer 
Cpp :: definition of singly linkedlist 
Cpp :: floor and ceil in cpp 
Cpp :: how to modify 2d array in function c++ 
Cpp :: && c++ 
Cpp :: inverted triangle c++ 
Cpp :: C++ ss 
Cpp :: c++ Closest Pair of Points | O(nlogn) Implementation 
Cpp :: even number program in c++ using for loop stack overflow 
Cpp :: how does sorting array works in c++ 
Cpp :: How to remove the % in zsh that show after running c++ file 
Cpp :: error when using base class members 
Cpp :: permutation in c++ with backtracking 
Cpp :: cpp get keystroke in console only 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =