Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Feb 10, 2022

[c/c++] 2차원 배열 곱 | matrix multiplication of 2-D array

 

#include <iostream>

using namespace std;

int main()

{

int c_matrix0[3][3] = {

{1, 2, 3},

{4, 5, 6},

{7, 8, 9}

};

int c_matrix1[3][3] = {

{1, 2, 3},

{4, 5, 6},

{7, 8, 9}

};

int multi_matrix[3][3] = {};

for (int i = 0; i < 3; i++)

{

for (int j = 0; j < 3; j++)

{

for (int k = 0; k < 3; k++)

{

multi_matrix[i][j] +=  c_matrix0[i][k] * c_matrix1[k][j];

}

}

}

for (int i = 0; i < 3; i++)

{

for (int j = 0; j < 3; j++)

{

cout << multi_matrix[i][j] << " ";

}

cout << endl;

}

}

Jan 30, 2022

[c/c++] 2차원 배열 사용 | 2-D array

 

#include <iostream>

using namespace std;

int main()

{

int c_matrix[3][3] = {

{1, 2, 3},

{4, 5, 6},

{7, 8, 9}

};

for (int i = 0; i < 3; i++)

{

for (int j = 0; j < 3; j++)

{

cout << c_matrix[i][j] << " ";

}

cout << endl;

}

}

Jan 22, 2022

[c/c++] 1차원 배열 사용 | 1-D array


#include <iostream>

using namespace std;

int main()

{

int c_nums[3] = { 1, 2, 3 };

int size = sizeof(c_nums) / sizeof(int);


for (int i = 0; i < size; ++i)

{

cout << c_nums[i] << " ";

}

cout << endl;

}

Mar 8, 2020

C/C++ normal distribution example (C/C++ 정규분포 예제)

- Example of normal distribution implemented in C/C++language.
- C/C++ 로 구현한 정규분포 예제 

//////////////////////////////////////////////////////////////////

#include <random>

int main(void){

 default_random_engine generator;
 normal_distribution<double> distribution(0,1); // mean: 0, standard deviation: 1

 while(1){

 double number = distribution(generator);
 cout<<"#:"<<number<<endl;

 }
 return 0;
}
//////////////////////////////////////////////////////////////////

* Screen shot of printed output data (출력된 데이터 스크린 샷)

//////////////////////////////////////////////////////////////////
* Plot in MATLAB (MATLAB 에서 plot한 그래프)