Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
i.zyryanov1
other
Commits
12345ca2
Commit
12345ca2
authored
1 year ago
by
i.zyryanov1
Browse files
Options
Download
Plain Diff
Merge branch 'i.zyryanov1-master-patch-74402' into 'master'
homework 29.09 See merge request
!1
parents
b1c20c7f
8b57bcac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
9 deletions
+38
-9
homework(17-09-2022)/src/main.c
homework(17-09-2022)/src/main.c
+38
-9
No files found.
homework(17-09-2022)/src/main.c
View file @
12345ca2
...
...
@@ -38,27 +38,56 @@ int main() {
}
int
**
allocateMatrix
(
int
n
,
int
m
)
{
// write here your implementation
return
NULL
;
int
**
matrix
=
malloc
(
n
*
sizeof
(
int
*
));
assert
(
matrix
!=
NULL
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
matrix
[
i
]
=
malloc
(
m
*
sizeof
(
int
));
assert
(
matrix
[
i
]
!=
NULL
);
}
return
matrix
;
}
void
freeMatrix
(
int
**
matrix
,
int
n
)
{
// write here your implementation
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
free
(
matrix
[
i
]);
}
free
(
matrix
);
}
void
scanfMatrix
(
int
**
matrix
,
int
n
,
int
m
)
{
// write here your implementation
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
m
;
j
++
)
{
scanf
(
"%d"
,
&
matrix
[
i
][
j
]);
}
}
}
void
printfMatrix
(
int
**
matrix
,
int
n
,
int
m
)
{
// write here your implementation
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
m
;
j
++
)
{
printf
(
"%d"
,
matrix
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
}
int
**
copyMatrix
(
int
**
matrix
,
int
n
,
int
m
)
{
// write here your implementation
return
NULL
;
int
**
copyMat
=
allocateMatrix
(
n
,
m
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
m
;
j
++
)
{
copyMat
[
i
][
j
]
=
matrix
[
i
][
j
];
}
}
return
copyMat
;
}
void
transposeMatrix
(
int
**
matrix
,
int
n
,
int
m
)
{
// write here your implementation
int
**
transposeMatrix
(
int
**
matrix
,
int
n
,
int
m
){
int
**
transposed
=
allocateMatrix
(
m
,
n
);
for
(
int
i
=
0
;
i
<
m
;
i
++
){
for
(
int
j
=
0
;
j
<
n
;
j
++
){
transposed
[
j
][
i
]
=
matrix
[
i
][
j
];
}
}
freeMatrix
(
matrix
,
n
);
return
transposed
;
}
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