Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
matjul
/
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
732ea521
authored
Nov 19, 2018
by
matjul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3ad0bcb2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
lab12task1.c
lab12task1.c
0 → 100644
View file @
732ea521
#include <stdio.h>
#include <math.h>
void
Magnitude
(
float
matrix
[
5
][
3
],
float
lenghts
[
10
]);
float
Compare
(
float
lenghts
[
10
]);
int
main
(){
float
matrix
[
5
][
3
]
=
{
{
1
,
3
.
1
,
21
},
{
2
,
-
3
.
2
,
23
},
{
2
.
3
,
12
.
8
,
2
},
{
2
,
1
.
4
,
-
23
},
{
12
,
2
,
-
2
.
3
}
};
float
lenghts
[
10
]
=
{
0
};
int
i
;
Magnitude
(
matrix
,
lenghts
);
for
(
i
=
0
;
i
<
10
;
i
++
){
printf
(
"%f
\n
"
,
lenghts
[
i
]);
}
printf
(
"The highest lenght is this crap: %f
\n
"
,
Compare
(
lenghts
));
return
0
;
}
void
Magnitude
(
float
matrix
[
5
][
3
],
float
lenghts
[
10
]){
int
i
,
j
,
z
;
float
sumOfSquares
=
0
;
int
x
=
0
;
for
(
i
=
0
;
i
<
5
;
i
++
){
for
(
j
=
0
;
j
<
i
;
j
++
){
for
(
z
=
0
;
z
<
3
;
z
++
){
sumOfSquares
+=
pow
(
matrix
[
i
][
z
]
-
matrix
[
j
][
z
],
2
);
}
lenghts
[
x
]
=
sqrt
(
sumOfSquares
);
x
++
;
sumOfSquares
=
0
;
}
}
}
float
Compare
(
float
lenghts
[
10
]){
int
i
;
float
len
=
lenghts
[
0
];
for
(
i
=
1
;
i
<
10
;
i
++
){
if
(
len
<
lenghts
[
i
]){
len
=
lenghts
[
i
];
}
}
return
len
;
}
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