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
de7d3a04
authored
Jan 15, 2025
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
164cef06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
Eeleksam/MassiivTaishaalikud.c
Eeleksam/MassiivTaishaalikud.c
0 → 100644
View file @
de7d3a04
/* Massiivi char f9[N][8] igast reaast sisestatakse sümbolid,
* kuni esimese täishäälikuni ja väljastatakse need massiivi tul[][]
* tähestikulises järjekorras. Massiivi tul väljastatkse ainult ladina tähed
* Massiiv f9 genereerida või täita klaviatuurilt.
* Massiiv f9 võib sisaldada ainult ladina tähti ja araabia numbreid. Max N=10.*/
#include <stdio.h>
#include <string.h> //lubab kasutada strlen käsku
#define max 10
//Prototüübid
int
RidadeArv
(
char
[]);
void
Sisestus
(
char
[],
int
,
char
[
max
][
8
]);
void
Sort
(
int
,
char
[
max
][
8
],
char
[
max
][
8
],
int
[
8
]);
void
TulemusMassiiv
(
char
[],
int
,
char
[
max
][
8
],
int
[]);
int
main
(
void
)
{
int
N
=
RidadeArv
(
"Sisestada ridade arv"
);
char
f9
[
max
][
8
];
char
tul
[
max
][
8
];
int
reapikkus
[
max
];
Sisestus
(
"Sisestada ridade väärtused"
,
N
,
f9
);
Sort
(
N
,
f9
,
tul
,
reapikkus
);
TulemusMassiiv
(
"Sorteeritud massiiv on:"
,
N
,
tul
,
reapikkus
);
return
0
;
}
int
RidadeArv
(
char
teade
[])
{
int
N
;
do
{
printf
(
"%s"
,
teade
);
scanf
(
"%d"
,
&
N
);
}
while
(
N
<
0
||
N
>
max
);
//N vahemikus 0...10
return
N
;
}
void
Sisestus
(
char
teade
[],
int
N
,
char
f9
[
max
][
8
])
{
int
i
;
int
j
;
char
a
;
printf
(
"%s
\n
"
,
teade
);
for
(
j
=
0
;
j
<
N
;
j
++
)
//ridade tsükkel
{
printf
(
"
\n
Rida nr %d
\n
"
,
j
);
for
(
i
=
0
;
i
<
8
;
i
++
)
//liikmed reas
{
printf
(
"Sisestada rea liige %d
\n
"
,
i
);
scanf
(
" %c"
,
&
a
);
f9
[
j
][
i
]
=
a
;
if
(
f9
[
j
][
i
]
==
'A'
||
f9
[
j
][
i
]
==
'E'
||
f9
[
j
][
i
]
==
'I'
||
f9
[
j
][
i
]
==
'O'
||
f9
[
j
][
i
]
==
'U'
||
f9
[
j
][
i
]
==
'a'
||
f9
[
j
][
i
]
==
'e'
||
f9
[
j
][
i
]
==
'i'
||
f9
[
j
][
i
]
==
'o'
||
f9
[
j
][
i
]
==
'u'
)
//kontroll, kas sisestati täishäälik
{
printf
(
"Sisestati täishäälik."
);
f9
[
j
][
i
+
1
]
=
'\0'
;
break
;
}
}
if
(
i
==
8
)
{
f9
[
j
][
i
]
=
'\0'
;
}
}
}
void
Sort
(
int
N
,
char
f9
[
max
][
8
],
char
tul
[
max
][
8
],
int
reapikkus
[
8
])
{
int
i
;
int
j
;
int
k
;
//sorteerimise jaoks lisamuutuja
char
Vahetus
;
for
(
j
=
0
;
j
<
N
;
j
++
)
//ridade tsükkel
{
reapikkus
[
j
]
=
strlen
(
f9
[
j
]);
for
(
i
=
0
;
i
<
reapikkus
[
j
]
-
1
;
i
++
)
{
for
(
k
=
0
;
k
<
reapikkus
[
j
]
-
1
-
i
;
k
++
)
{
if
(
f9
[
j
][
k
]
>
f9
[
j
][
k
+
1
])
{
Vahetus
=
f9
[
j
][
k
];
f9
[
j
][
k
]
=
f9
[
j
][
k
+
1
];
f9
[
j
][
k
+
1
]
=
Vahetus
;
}
}
}
for
(
i
=
0
;
i
<
reapikkus
[
j
];
i
++
)
{
if
((
f9
[
j
][
i
]
>=
'A'
&&
f9
[
j
][
i
]
<=
'Z'
)
||
(
f9
[
j
][
i
]
>=
'a'
&&
f9
[
j
][
i
]
<=
'z'
))
{
tul
[
j
][
i
]
=
f9
[
j
][
i
];
}
}
tul
[
j
][
reapikkus
[
j
]]
=
'\0'
;
}
}
void
TulemusMassiiv
(
char
teade
[],
int
N
,
char
tul
[
max
][
8
],
int
reapikkus
[])
{
int
i
;
int
j
;
printf
(
"%s"
,
teade
);
for
(
j
=
0
;
j
<
N
;
j
++
)
//ridade tsükkel
{
printf
(
"
\n
Rida nr %d: "
,
j
);
for
(
i
=
0
;
i
<
reapikkus
[
j
];
i
++
)
//liikmed reas
{
printf
(
"%c "
,
tul
[
j
][
i
]);
}
}
}
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