Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prog_exam_05
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
boris.stefanov
prog_exam_05
Commits
e782027f
Commit
e782027f
authored
2 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
save
parent
90e54c6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
ex1/Makefile
+2
-2
2 additions, 2 deletions
ex1/Makefile
ex1/ex1.c
+75
-0
75 additions, 0 deletions
ex1/ex1.c
with
78 additions
and
2 deletions
.gitignore
+
1
−
0
View file @
e782027f
build
*.o
*.txt
This diff is collapsed.
Click to expand it.
ex1/Makefile
+
2
−
2
View file @
e782027f
...
...
@@ -10,8 +10,8 @@ CC := gcc
CFLAGS
:=
-std
=
c11
-Wall
-Wextra
-pedantic
CFLAGS_DEBUG
:=
${
CFLAGS
}
-fsanitize
=
address
-fsanitize
=
leak
-g
-DDEBUG
LDEXTRA
:=
LDEXTRA_DEBUG
:=
LDEXTRA
:=
-lm
LDEXTRA_DEBUG
:=
-lm
LDFLAGS
:=
${
CFLAGS
}
${
LDEXTRA
}
LDFLAGS_DEBUG
:=
${
CFLAGS_DEBUG
}
${
LDEXTRA_DEBUG
}
...
...
This diff is collapsed.
Click to expand it.
ex1/ex1.c
+
75
−
0
View file @
e782027f
#include
<math.h>
#include
<stdio.h>
#include
<stdlib.h>
#define ROWS 5
#define COLS 4
#define ITERATIONS 10
double
**
alloc
(
const
int
m
,
const
int
n
)
{
double
**
a
=
malloc
(
m
*
sizeof
(
double
*
));
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
a
[
i
]
=
malloc
(
n
*
sizeof
(
double
));
}
return
a
;
}
void
destroy
(
double
**
a
,
const
int
m
)
{
for
(
int
i
=
0
;
i
<
m
;
++
i
)
{
free
(
a
[
i
]);
}
free
(
a
);
}
void
init
(
double
**
a
,
const
int
m
,
const
int
n
)
{
for
(
int
y
=
0
;
y
<
m
;
++
y
)
{
for
(
int
x
=
0
;
x
<
n
;
++
x
)
{
a
[
y
][
x
]
=
sqrt
(
y
+
x
);
}
}
}
void
mean
(
double
**
a
,
const
int
m
,
const
int
n
,
double
**
r
)
{
for
(
int
y
=
0
;
y
<
m
;
++
y
)
{
for
(
int
x
=
0
;
x
<
n
;
++
x
)
{
if
(
(
y
==
0
)
|
(
y
==
(
m
-
1
))
|
(
x
==
0
)
|
(
x
==
(
n
-
1
))
)
{
r
[
y
][
x
]
=
a
[
y
][
x
];
}
else
{
r
[
y
][
x
]
=
(
a
[
y
][
x
+
1
]
+
a
[
y
][
x
-
1
]
+
a
[
y
+
1
][
x
]
+
a
[
y
-
1
][
x
]
+
a
[
y
][
x
]
)
/
5
.
0
;
}
}
}
}
void
print
(
double
**
a
,
const
int
m
,
const
int
n
)
{
for
(
int
y
=
0
;
y
<
m
;
++
y
)
{
for
(
int
x
=
0
;
x
<
n
;
++
x
)
{
printf
(
"%lf"
,
a
[
y
][
x
]);
}
printf
(
"
\n
"
);
}
}
int
main
()
{
double
**
m
=
alloc
(
ROWS
,
COLS
);
double
**
n
=
alloc
(
ROWS
,
COLS
);
init
(
m
,
ROWS
,
COLS
);
double
**
swap
;
for
(
int
i
=
0
;
i
<
ITERATIONS
;
++
i
)
{
mean
(
m
,
ROWS
,
COLS
,
n
);
swap
=
m
;
m
=
n
;
n
=
swap
;
}
print
(
m
,
ROWS
,
COLS
);
destroy
(
m
,
ROWS
);
destroy
(
n
,
ROWS
);
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment