Hello!
Yesterday when I was in a lecture of num. methods.My Professor said that programing is basically an automation of everyday tasks and time consuming excersises.
That got me thinking to when the difference engine was designed because it not only wanted to achieve that task but wanted to calculate the typeset mathematical tables.
So I took it as a challenge upon myself to do what Charles Babbage did.
But instead of calculation of the typeset math tables.
I decided to use the calculation of matrices(multiplication,rank,determinant...)
Because I thought that a self-respecting(at least in my opinion) programmer should be able to do these sort of automated math calculations.
And my questions are:
Have I gotten the core principles of programming?
I have managed to complete the beginner exercises on this forum with the bunny graduation but I don't think I'm skilled enough to move on other projects how can I determine if I'm skilled enough or not?
And what do you think of part of my code that multiplies matrices?
I know it works well but I feel that it isn't perfect(why do I have this feeling?And not only in this exercise but everytime I program why?).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
int matrixnumber=0,rowcol=0;
std::cout<<"Enter the size of the matrix you want to multiply ";
std::cin>>rowcol;
int **matrixa=new int *[rowcol];
int **matrixb=new int *[rowcol];
int **matrixc=new int *[rowcol];
for(int i=0;i<rowcol;i++)
{
*(matrixa+i)=new int [rowcol];
*(matrixb+i)=new int [rowcol];
*(matrixc+i)=new int [rowcol];
}
for(int i=0;i<rowcol;i++)
{
for(int j=0;j<rowcol;j++)
{
*(*(matrixa+i)+j)=rand()%10;
*(*(matrixb+i)+j)=rand()%10;
}
}
for(int i=0;i<rowcol;i++)
{
std::cout<<"|";
for(int j=0;j<rowcol;j++)
{
*(*(matrixc+i)+j)=*(*(matrixa+i)+j)*(*(*(matrixb+j)+i));
std::cout<<" "<<*(*(matrixc+i)+j)<<" ";
}
std::cout<<"|\n";
}
for(int i=0;i<rowcol;i++)
{
delete [] *(matrixa+i);
delete [] *(matrixb+i);
delete [] *(matrixc+i);
}
delete [] matrixa;
delete [] matrixb;
delete [] matrixc;
}
|
Thank you for your time!