* --Originally published at The Talking Chalk*

## In love with the matrix

Last summer, I wandered in the school’s library wondering **what the f*** was I doing with my life?**, then I found a **linear algebra** book with the concept of **matrices**. Though I am not an expert on them, and my knowledge of their uses is quite little, the matrices helped me to make my summer a **bit more funny** and less depressive.

## The code

#include <vector>

#include <iostream>

using namespace std;

int main()

{

int rows, columns, numbers[100][100], i, j;

vector<int> Vector1, Vector2, Vector3, Vector4, ask1, ask2, ask3, ask4;

Vector1.push_back(2);

Vector1.push_back(5);

Vector1.push_back(7);

Vector1.push_back(10);

Vector2.push_back(1);

Vector2.push_back(7);

Vector2.push_back(6);

Vector2.push_back(11);

Vector3.push_back(5);

Vector3.push_back(9);

Vector3.push_back(8);

Vector3.push_back(0);

Vector4.push_back(9);

Vector4.push_back(5);

Vector4.push_back(123);

Vector4.push_back(99454);

cout<<Vector1[0]<<endl<<Vector2[1]<<endl<<Vector3[2]<<endl<<Vector4[3]<<endl;

cout<<“…”<<endl;

cout<<“Now we are going to build a matrix”<<endl;

cout<<“how many columns shall it have?: “<<endl;

cin>>columns;

cout<<“And how many rows? “<<endl;

cin>>rows;

cout<<“Excellent! Now give in the value for each element of the matrix. Row[“<<i<<“], Column[“<<j<<“]”<<endl;

for(j=0;j<columns;j++)

{

for(i=0;i<rows;i++)

{

cin>>numbers[i][j];

}

}

for(j=0;j<columns;j++)

{

for(i=0;i<rows;i++)

{

cout<<numbers[i][j];

}

cout<<endl;

}

return 0;

}

## How to?

Though some vectors have predeterminated values, you can create your own **matrix** with the number of rows and columns you like, inserting whatever numbers you desire to (though the matrix lacks aestethics).

## The Topics

**#Matrices and vectors**

**#Nested loops**