#include <stdio.h>
#include <stdlib.h>
int** matrix_mul(int **s, int **t, int N);
int main(int argc, char** argv){
int A[3][3] = {
{1, 1, 2},
{1, 0, 1},
{0, 3, 0}
};
int B[3][3] = {
{2, 1, 3},
{1, 3, 2},
{1, 2, 0}
};
int *parr_A[3] = {A[0], A[1], A[2]};
int *parr_B[3] = {B[0], B[1], B[2]};
int **AB = (void*)0;
int i, j, N = 3;
printf("A : \n");
for(i = 0; i < N; i++){
for(j = 0; j < N; j++){
printf("%d ", A[i][j]);
}
printf("\n");
}
printf("B : \n");
for(i = 0; i < N; i++){
for(j = 0; j < N; j++){
printf("%d ", B[i][j]);
}
printf("\n");
}
AB = matrix_mul(parr_A, parr_B, N);
if(AB){
printf("A x B : \n");
for(i = 0; i < N; i++){
for(j = 0; j < N; j++){
printf("%d ", AB[i][j]);
}
printf("\n");
}
}
return 0;
}
int** matrix_mul(int **s, int **t, int N){
//여기 작성
}
#include <stdio.h>
int main(void)
{
int *i = (int *)malloc(sizeof(int) * 1000000);
int *count_i = (int *)malloc(sizeof(int) * 1000000);
int input;
scanf("%d", &input);
for (int sentinel = 0; sentinel < input; sentinel++)
{
scanf("%d", &i[sentinel]);
}
for (int sentinel = 0; sentinel < input; sentinel++)
{
count_i[sentinel] = i[input - sentinel - 1];
}
for (int sentinel = 0; sentinel < input; sentinel++)
{
printf("%d ", count_i[sentinel]);
}
printf("\n");
return 0;
}
#2
int **matrix_mul(int **s, int **t, int N)
{
int **M = (int *)malloc(sizeof(int)*N);
int value;
for (int sentinel = 0; sentinel < N; sentinel++)
*(M + sentinel) = (int *)malloc(sizeof(int)*N);
for (int sentinel = 0; sentinel < N; sentinel++)
{
for (int sentinel_2 = 0; sentinel_2 < N; sentinel_2++)
{
value = 0;
for (int sentinel_3 = 0; sentinel_3 < N; sentinel_3++)
{
value += s[sentinel][sentinel_3] * t[sentinel_3][sentinel_2];
}
M[sentinel][sentinel_2] = value;
}
}
return M;
}
#include <stdio.h>
int main()
{
int arr[10000];
int min[10000];
int i,j, temp;
printf("자연수를 몇개 입력하실 건가요? : ");
scanf_s("%d", &i);
printf("자연수를 입력하세요. : \n");
for (j = 0; j < i; j++)
{
scanf_s("%d", &arr[j]);
}
for (j = 0; j < i / 2; j++)
{
min[j] = arr[i - j - 1];
}
for (j = i/2; j < i; j++)
{
min[j] = arr[i - j - 1];
}
printf("배열을 뒤집으면! \n");
for (j = 0; j < i ; j++)
{
printf("%d \n", min[j]);
}
return 0;
}
#2
#include <stdio.h>
#include <stdlib.h>
int** matrix_mul(int **s, int **t, int N);
int main(int argc, char** argv)
{
int A[3][3] = {
{ 1, 1, 2 },
{ 1, 0, 1 },
{ 0, 3, 0 }
};
int B[3][3] = {
{ 2, 1, 3 },
{ 1, 3, 2 },
{ 1, 2, 0 }
};
int *parr_A[3] = { A[0], A[1], A[2] };
int *parr_B[3] = { B[0], B[1], B[2] };
int **AB = (void*)0;
int i, j, N = 3;
printf("A : \n");
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
printf("%d ", A[i][j]);
}
printf("\n");
}
printf("B : \n");
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
printf("%d ", B[i][j]);
}
printf("\n");
}
AB = matrix_mul(parr_A, parr_B, N);
if (AB) {
printf("A x B : \n");
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
printf("%d ", AB[i][j]);
}
printf("\n");
}
}
return 0;
}
int** matrix_mul(int **s, int **t, int N)
{
int** re = (int**)malloc(sizeof(int*)*N);
int i,j,k,o;
for (i = 0; i < N; i++)
{
re[i] = (int*)malloc(sizeof(int)*N);
}
for (j = 0; j < N; j++)
{
for (k = 0; k < N; k++)
{
re[j][k] = 0;
for (o = 0; o < N; o++)
{
re[j][k] += s[j][o] * t[o][k];
}
}
}
return re;
}