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
977f527d
authored
Oct 12, 2024
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MassiivSortFunktsioonid.c
parent
1cc7a17e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
44 deletions
Tunnitöö 10.10.24/MassiivSortFunktsioonid.c
Tunnitöö 10.10.24/MassiivSortFunktsioonid.c
View file @
977f527d
/*Kas
utaja sisestab 2 massiivi klaviatuurilt K1[n1], K2[n2]
/*Kas
utaja sisestab 2 massiivi klaviatuurilt K1[n1], K2[n2]
...
...
@@ -7,76 +7,130 @@
#include <stdio.h>
//Prototüübid
int
sisestus
(
char
[]);
void
maatriksSisse
(
int
,
int
,
int
[],
int
[]);
void
v
ä
ljastusM
(
int
,
int
,
int
[]);
int
sisestusN1
();
int
sisestusN2
();
int
sisestusM
();
void
MassiivSisse
(
int
,
int
,
int
[],
int
[]);
void
V
ä
ljastusAlgne
(
int
,
int
,
int
[],
int
[]);
void
YhineMassiiv
(
int
,
int
,
int
,
int
[],
int
[],
int
[]);
void
Sortimine
(
int
,
int
[]
,
int
[]
);
void
V
ä
ljastus
(
int
,
char
[]);
void
Sortimine
(
int
,
int
[]);
void
V
ä
ljastus
(
int
,
int
,
int
[]);
int
main
(
void
)
{
int
n1
,
n2
,
m
,
n
,
i
;
int
maatriksk1
[];
int
maatriksk2
[];
int
K
[];
m
=
sisestus
(
"Sisesta ruutmaatriksi mõõde:"
);
maatriksSisse
(
n1
,
n2
,
maatriksk1
[],
maatriksk2
[]);
v
ä
ljastusMM
(
n1
,
n2
,
maatriksk1
[],
maatriksk2
[]);
YhineMassiiv
(
n
,
n1
,
n2
,
maatriksk1
[],
maatriksk2
[],
K
[
i
]);
Sortimine
(
n
,
K
[
i
],
K
[
i
+
1
],);
V
ä
ljastus
(
m
,
K
[
i
]);
int
n1
=
sisestusN1
();
int
n2
=
sisestusN2
();
int
M
=
sisestusM
();
int
n
=
n1
+
n2
;
int
K1
[
n1
];
int
K2
[
n2
];
int
K
[
n
];
MassiivSisse
(
n1
,
n2
,
K1
,
K2
);
V
ä
ljastusAlgne
(
n1
,
n2
,
K1
,
K2
);
YhineMassiiv
(
n
,
n1
,
n2
,
K
,
K1
,
K2
);
Sortimine
(
n
,
K
);
V
ä
ljastus
(
M
,
n
,
K
);
return
0
;
}
/*
int sisestus(char teade[]){
int m;
printf("%s", teade);
scanf("%d", &m);
return m;
void maatriksSisse(int n1, int n2, int k1[n1], int k2[n2]) //Maatriksite sisselugemine
int
sisestusN1
()
{
int
n1
;
printf
(
"Sisesta 1. massiivi liikmete arv n1"
);
scanf
(
"%d"
,
&
n1
);
return
n1
;
}
int
sisestusN2
()
{
int
n2
;
printf
(
"Sisesta 2. massiivi liikmete arv n2"
);
scanf
(
"%d"
,
&
n2
);
return
n2
;
}
int
sisestusM
()
{
int
M
;
printf
(
"Sisesta väljastatavate elementide arv M."
);
scanf
(
"%d"
,
&
M
);
return
M
;
}
void
MassiivSisse
(
int
n1
,
int
n2
,
int
K1
[],
int
K2
[])
//Massiivide sisselugemine
{
int
i
;
for
(
i
=
0
;
i
<
n1
;
i
++
)
{
printf
(
"Sisesta 1. massiivi element nr %d: "
,
i
);
scanf
(
"%d"
,
&
K1
[
i
]);
}
for
(
i
=
0
;
i
<
n2
;
i
++
)
{
printf
(
"Sisesta 2. massiivi element nr %d: "
,
i
);
scanf
(
"%d"
,
&
K2
[
i
]);
}
}
void
V
ä
ljastusAlgne
(
int
n1
,
int
n2
,
int
K1
[],
int
K2
[])
{
int
i
;
for(i=0;i<n1;i++){
printf("Sisesta 1. massiivi element nr %d:", i);
scanf("%d\n", &k1[i]);
printf
(
"
\n
Sisestatud massiiv nr 1. on: "
);
for
(
i
=
0
;
i
<
n1
;
i
++
)
{
printf
(
"%d "
,
K1
[
i
]);
}
for(i=0;i<n1;i++){
printf("Sisesta 2. massiivi element nr %d:", i);
scanf("%d\n", &k2[i]);
printf
(
"
\n
Sisestatud massiiv nr 2. on: "
);
for
(
i
=
0
;
i
<
n2
;
i
++
)
{
printf
(
"%d "
,
K2
[
i
]);
}
}
/*
void YhineMassiiv(int n
1, int n2, int k1[n1], int k2[n2], int K[i])
void
YhineMassiiv
(
int
n
,
int
n1
,
int
n2
,
int
K1
[],
int
K2
[],
int
K
[])
//K[n] moodustamine
{
int
n,i,j
;
for(i=0;i<n1;i++)
//K[n] moodustamine
int
i
;
for
(
i
=
0
;
i
<
n1
;
i
++
)
{
n=n1+n2;
K[n]=n;
K
[
i
]
=
K1
[
i
];
}
i=0;
for(j=0;j<n;j++)
for
(
i
=
n1
;
i
<
n
;
i
++
)
{
K[
j
]=K2[i-n1];
K
[
i
]
=
K2
[
i
-
n1
];
}
}
/*
void Sortimine(
n,maatriks[n
])
void
Sortimine
(
int
n
,
int
K
[
])
{
int
Vahetus
;
int
i
;
int
sorditud
=
0
;
while
(
sorditud
==
0
)
{
sorditud
=
1
;
for
(
i
=
0
;
i
<
(
n
-
1
);
i
++
)
{
if
(
K
[
i
]
>
K
[
i
+
1
])
{
Vahetus
=
K
[
i
];
K
[
i
]
=
K
[
i
+
1
];
K
[
i
+
1
]
=
Vahetus
;
sorditud
=
0
;
}
}
}
}
void
väljastusM(int n1, int n2, int K2[n2], int K1[n1
])
void
V
ä
ljastus
(
int
M
,
int
n
,
int
K
[
])
{
printf("%s", );
int
i
;
for (i = 0; i < m; i++)
printf
(
"
\n
%d elementi sorditud massiivist: "
,
M
);
for
(
i
=
0
;
i
<
M
&&
i
<
n
;
i
++
)
{
printf
(
"%d "
,
K
[
i
]);
}
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