Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
viakul
/
iax0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9820b241
authored
Sep 24, 2018
by
viakul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mATRIXoPERATIONS
parent
d26a20e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
0 deletions
lab4/matrixOperation.c
lab4/matrixOperation.c
0 → 100644
View file @
9820b241
#include <stdio.h>
int
main
()
{
int
n
;
printf
(
"write the size of the matrix
\n
"
);
scanf
(
"%d"
,
&
n
);
int
array1
[
n
][
n
];
int
array2
[
n
][
n
];
int
sum12
[
n
][
n
];
int
dif12
[
n
][
n
];
int
mult1
=
1
;
int
mult2
=
1
;
printf
(
"Fill the first matrix
\n
"
);
printf
(
"Fill the first raw
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
scanf
(
"%d"
,
&
array1
[
i
][
j
]);
}
if
(
i
<
n
-
1
){
printf
(
"Next raw
\n
"
);
}
}
printf
(
"The first matrix is:
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
printf
(
"%d "
,
array1
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"Fill the second matrix
\n
"
);
printf
(
"Fill the first raw
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
scanf
(
"%d"
,
&
array2
[
i
][
j
]);
}
if
(
i
<
n
-
1
){
printf
(
"Next raw
\n
"
);
}
}
printf
(
"The second matrix is:
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
printf
(
"%d "
,
array2
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"The sum of matrixes is is:
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
sum12
[
i
][
j
]
=
array2
[
i
][
j
]
+
array1
[
i
][
j
];
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
printf
(
"%d "
,
sum12
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"The diferrence of matrixes is :
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
dif12
[
i
][
j
]
=
array1
[
i
][
j
]
-
array2
[
i
][
j
];
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
printf
(
"%d "
,
dif12
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"The sum of the multiplication of elements on the diagonals for the first matrix is:
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
mult1
=
mult1
*
array1
[
i
][
i
];
mult2
=
mult2
*
array1
[
n
-
1
-
i
][
n
-
1
-
i
];
}
printf
(
"%d
\n
"
,
mult1
+
mult2
);
mult1
=
1
;
mult2
=
1
;
printf
(
"The sum of the multiplication of elements on the diagonals for the second matrix is:
\n
"
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
mult1
=
mult1
*
array2
[
i
][
i
];
mult2
=
mult2
*
array2
[
n
-
1
-
i
][
n
-
1
-
i
];
}
printf
(
"%d"
,
mult1
+
mult2
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment