Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ilahma
/
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
d046ff05
authored
6 years ago
by
ilahma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3f38bf38
master
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
Lab4/lab4_1.c
Lab4/lab4_1.c
0 → 100644
View file @
d046ff05
#include <stdio.h>
int
main
()
{
int
r
;
//r - row of matrix
int
c
;
//c stands for columns
int
i
;
int
j
;
float
A
[
3
][
3
];
float
B
[
3
][
3
];
float
sumAB
[
3
][
3
];
float
subtractAB
[
3
][
3
];
float
multiplicationA
[
3
][
3
];
float
multiplicationB
[
3
][
3
];
printf
(
"Please, enter the rows and columns of matrices:
\n
THEY SHOULD BE EQUAL!!!
\n
"
);
scanf
(
"%d%d"
,
&
r
,
&
c
);
printf
(
"Please, enter the elements of the first matrix:
\n
"
);
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
j
=
0
;
j
<
c
;
j
++
)
{
scanf
(
"%f"
,
&
A
[
i
][
j
]);
}
}
printf
(
"Please, enter the elements of the second matrix:
\n
"
);
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
j
=
0
;
j
<
c
;
j
++
)
{
scanf
(
"%f"
,
&
B
[
i
][
j
]);
}
}
printf
(
"SUM
\n
"
);
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
j
=
0
;
j
<
c
;
j
++
)
{
sumAB
[
i
][
j
]
=
A
[
i
][
j
]
+
B
[
i
][
j
];
printf
(
"%f, "
,
sumAB
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"SUBTRACTION
\n
"
);
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
j
=
0
;
j
<
c
;
j
++
)
{
subtractAB
[
i
][
j
]
=
A
[
i
][
j
]
-
B
[
i
][
j
];
printf
(
"%f, "
,
subtractAB
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"Diagonals
\n
"
);
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
j
=
0
;
j
<
c
;
j
++
)
{
if
(
i
==
j
)
{
multiplicationA
[
i
][
j
]
=
A
[
i
][
j
]
*
multiplicationA
[
i
][
j
];
}
}
printf
(
"
\n
"
);
printf
(
"%f, "
,
multiplicationA
[
i
][
j
]);
}
return
0
;
}
This diff is collapsed.
Click to expand it.
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