Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jürgen Hein
/
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
6f447b6f
authored
Oct 14, 2024
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parandused, lõppvastus vale veel Kodutoo2MassiividLiitmine.c
parent
42997e23
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
37 deletions
Kodutöö 2/Kodutoo2MassiividLiitmine.c
Kodutöö 2/Kodutoo2MassiividLiitmine.c
View file @
6f447b6f
/* Ko
dutöö 2. Variant 4.
/* Ko
dutöö 2. Variant 4.
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
//Prototüübid
//Prototüübid
int
SisestusN
();
int
SisestusN
();
int
SisestusM
();
int
SisestusM
();
int
SisestusK
();
int
SisestusL
();
int
SisestusL
();
int
SisestusK
();
int
SisestusCRida
(
int
,
int
);
int
SisestusCRida
(
int
,
int
);
int
SisestusCVeerg
(
int
,
int
);
int
SisestusCVeerg
(
int
,
int
);
void
MaatriksSisestus
(
int
,
int
,
int
,
int
,
double
[][
10
],
double
[][
10
]);
void
MaatriksSisestus
(
int
,
int
,
int
,
int
,
double
[][
10
],
double
[][
10
]);
...
@@ -23,8 +23,8 @@ int main(void)
...
@@ -23,8 +23,8 @@ int main(void)
{
{
int
n
=
SisestusN
();
int
n
=
SisestusN
();
int
m
=
SisestusM
();
int
m
=
SisestusM
();
int
k
=
SisestusK
();
int
l
=
SisestusL
();
int
l
=
SisestusL
();
int
k
=
SisestusK
();
double
A
[
n
][
m
];
double
A
[
n
][
m
];
double
B
[
k
][
l
];
double
B
[
k
][
l
];
int
CRida
=
SisestusCRida
(
n
,
k
);
int
CRida
=
SisestusCRida
(
n
,
k
);
...
@@ -44,7 +44,7 @@ int SisestusN()
...
@@ -44,7 +44,7 @@ int SisestusN()
int
n
;
int
n
;
do
do
{
{
printf
(
"Sisestage A
rida
de arv
\n
"
);
printf
(
"Sisestage A
veergu
de arv
\n
"
);
scanf
(
"%d"
,
&
n
);
scanf
(
"%d"
,
&
n
);
if
(
n
<=
1
||
n
>=
10
)
if
(
n
<=
1
||
n
>=
10
)
{
{
...
@@ -59,7 +59,7 @@ int SisestusM()
...
@@ -59,7 +59,7 @@ int SisestusM()
int
m
;
int
m
;
do
do
{
{
printf
(
"Sisestage A
veergu
de arv
\n
"
);
printf
(
"Sisestage A
rida
de arv
\n
"
);
scanf
(
"%d"
,
&
m
);
scanf
(
"%d"
,
&
m
);
if
(
m
<=
1
||
m
>=
10
)
if
(
m
<=
1
||
m
>=
10
)
{
{
...
@@ -68,20 +68,7 @@ int SisestusM()
...
@@ -68,20 +68,7 @@ int SisestusM()
}
while
(
m
<=
1
||
m
>=
10
);
}
while
(
m
<=
1
||
m
>=
10
);
return
m
;
return
m
;
}
}
int
SisestusK
()
{
int
k
;
do
{
printf
(
"Sisestage B ridade arv
\n
"
);
scanf
(
"%d"
,
&
k
);
if
(
k
<=
1
||
k
>=
10
)
{
printf
(
"Sisestatud väärtus ei sobi, sisestage täisarv vahemikus 1...10."
);
}
}
while
(
k
<=
1
||
k
>=
10
);
return
k
;
}
int
SisestusL
()
int
SisestusL
()
{
{
int
l
;
int
l
;
...
@@ -97,15 +84,31 @@ int SisestusL()
...
@@ -97,15 +84,31 @@ int SisestusL()
return
l
;
return
l
;
}
}
int
SisestusK
()
{
int
k
;
do
{
printf
(
"Sisestage B ridade arv
\n
"
);
scanf
(
"%d"
,
&
k
);
if
(
k
<=
1
||
k
>=
10
)
{
printf
(
"Sisestatud väärtus ei sobi, sisestage täisarv vahemikus 1...10."
);
}
}
while
(
k
<=
1
||
k
>=
10
);
return
k
;
}
int
SisestusCRida
(
int
n
,
int
k
)
int
SisestusCRida
(
int
n
,
int
k
)
{
{
int
CRida
;
int
CRida
;
if
(
n
<
k
)
if
(
n
<
k
)
{
{
CRida
=
k
;
CRida
=
n
;
}
else
}
else
{
{
CRida
=
n
;
CRida
=
k
;
}
}
return
CRida
;
return
CRida
;
}
}
...
@@ -114,10 +117,10 @@ int SisestusCVeerg(int m, int l)
...
@@ -114,10 +117,10 @@ int SisestusCVeerg(int m, int l)
int
CVeerg
;
int
CVeerg
;
if
(
m
<
l
)
if
(
m
<
l
)
{
{
CVeerg
=
l
;
CVeerg
=
m
;
}
else
}
else
{
{
CVeerg
=
m
;
CVeerg
=
l
;
}
}
return
CVeerg
;
return
CVeerg
;
}
}
...
@@ -125,13 +128,13 @@ int SisestusCVeerg(int m, int l)
...
@@ -125,13 +128,13 @@ int SisestusCVeerg(int m, int l)
void
MaatriksSisestus
(
int
n
,
int
m
,
int
k
,
int
l
,
double
A
[][
m
],
double
B
[][
l
])
void
MaatriksSisestus
(
int
n
,
int
m
,
int
k
,
int
l
,
double
A
[][
m
],
double
B
[][
l
])
{
{
int
i
,
j
,
Kontroll
;
//järjenumbrid, scanf kontrolli muutuja
int
i
,
j
,
Kontroll
;
//järjenumbrid, scanf kontrolli muutuja
for
(
j
=
0
;
j
<
m
;
j
++
)
for
(
i
=
0
;
i
<
m
;
i
++
)
{
{
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
j
=
0
;
j
<
n
;
j
++
)
{
{
do
do
{
{
printf
(
"Sisestada
väärtus A[%d]
[%d]"
,
i
,
j
);
printf
(
"Sisestada
A väärtus veerg [%d], rida
[%d]"
,
i
,
j
);
Kontroll
=
scanf
(
"%lf"
,
&
A
[
i
][
j
]);
Kontroll
=
scanf
(
"%lf"
,
&
A
[
i
][
j
]);
if
(
Kontroll
==
0
)
if
(
Kontroll
==
0
)
{
{
...
@@ -141,13 +144,13 @@ void MaatriksSisestus(int n, int m, int k, int l, double A[][m], double B[][l])
...
@@ -141,13 +144,13 @@ void MaatriksSisestus(int n, int m, int k, int l, double A[][m], double B[][l])
}
while
(
Kontroll
==
0
);
//reaalarvu kontroll
}
while
(
Kontroll
==
0
);
//reaalarvu kontroll
}
}
}
}
for
(
j
=
0
;
j
<
l
;
j
++
)
{
for
(
i
=
0
;
i
<
k
;
i
++
)
for
(
i
=
0
;
i
<
k
;
i
++
)
{
{
for
(
j
=
0
;
j
<
l
;
j
++
)
{
do
do
{
{
printf
(
"Sisestada
väärtus B[%d]
[%d]"
,
i
,
j
);
printf
(
"Sisestada
B väärtus veerg [%d], rida
[%d]"
,
i
,
j
);
Kontroll
=
scanf
(
"%lf"
,
&
B
[
i
][
j
]);
Kontroll
=
scanf
(
"%lf"
,
&
B
[
i
][
j
]);
if
(
Kontroll
==
0
)
if
(
Kontroll
==
0
)
{
{
...
@@ -163,9 +166,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
...
@@ -163,9 +166,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
{
{
int
i
,
j
;
int
i
,
j
;
printf
(
"
\n
Sisestatud maatriks A:
\n
"
);
printf
(
"
\n
Sisestatud maatriks A:
\n
"
);
for
(
j
=
0
;
j
<
m
;
j
++
)
for
(
i
=
0
;
i
<
m
;
i
++
)
{
{
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
j
=
0
;
j
<
n
;
j
++
)
{
{
printf
(
"%lf "
,
A
[
i
][
j
]);
printf
(
"%lf "
,
A
[
i
][
j
]);
}
}
...
@@ -173,9 +176,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
...
@@ -173,9 +176,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
}
}
printf
(
"
\n
Sisestatud maatriks B:
\n
"
);
printf
(
"
\n
Sisestatud maatriks B:
\n
"
);
for
(
j
=
0
;
j
<
l
;
j
++
)
for
(
i
=
0
;
i
<
l
;
i
++
)
{
{
for
(
i
=
0
;
i
<
k
;
i
++
)
for
(
j
=
0
;
j
<
k
;
j
++
)
{
{
printf
(
"%lf "
,
B
[
i
][
j
]);
printf
(
"%lf "
,
B
[
i
][
j
]);
}
}
...
@@ -186,9 +189,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
...
@@ -186,9 +189,9 @@ void VäljastusAlgne(int n, int m, int k, int l, double A[][m], double B[][l])
void
MaatriksLiitmine
(
int
CRida
,
int
CVeerg
,
double
A
[][
CVeerg
],
double
B
[][
CVeerg
],
double
C
[][
CVeerg
])
void
MaatriksLiitmine
(
int
CRida
,
int
CVeerg
,
double
A
[][
CVeerg
],
double
B
[][
CVeerg
],
double
C
[][
CVeerg
])
{
{
int
j
,
i
;
int
j
,
i
;
for
(
j
=
0
;
j
<
CVeerg
;
j
++
)
for
(
i
=
0
;
i
<
CVeerg
;
i
++
)
{
{
for
(
i
=
0
;
i
<
CRida
;
i
++
)
for
(
j
=
0
;
j
<
CRida
;
j
++
)
{
{
C
[
i
][
j
]
=
A
[
i
][
j
]
+
B
[
i
][
j
];
C
[
i
][
j
]
=
A
[
i
][
j
]
+
B
[
i
][
j
];
...
@@ -199,10 +202,10 @@ void CVäljastus(int CRida, int CVeerg, double C[][CVeerg])
...
@@ -199,10 +202,10 @@ void CVäljastus(int CRida, int CVeerg, double C[][CVeerg])
{
{
int
j
,
i
;
int
j
,
i
;
printf
(
"
\n
Maatriks C:
\n
"
);
printf
(
"
\n
Maatriks C:
\n
"
);
for
(
j
=
0
;
j
<
CVeerg
;
j
++
)
{
for
(
i
=
0
;
i
<
CRida
;
i
++
)
for
(
i
=
0
;
i
<
CRida
;
i
++
)
{
{
for
(
j
=
0
;
j
<
CVeerg
;
j
++
)
{
printf
(
"%lf "
,
C
[
i
][
j
]);
printf
(
"%lf "
,
C
[
i
][
j
]);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
...
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