Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alxm2023
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
alxm2023
Commits
215f772e
Commit
215f772e
authored
Dec 21, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zajęcia 21 grudnia
parent
b0c0a119
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
0 deletions
+108
-0
sortowanie.cpp
20231221/sortowanie.cpp
+50
-0
wylosuj_tablice.cpp
20231221/wylosuj_tablice.cpp
+27
-0
zgadywanie.cpp
20231221/zgadywanie.cpp
+31
-0
No files found.
20231221/sortowanie.cpp
0 → 100644
View file @
215f772e
#include <iostream>
using
namespace
std
;
const
int
SIZE
=
20
;
void
wypelnij_losowo
(
int
t
[],
int
rozmiar
,
int
zakres
)
{
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
t
[
i
]
=
rand
()
%
zakres
;
}
}
void
wypisz
(
int
t
[],
int
rozmiar
)
{
for
(
int
i
=
0
;
i
<
rozmiar
;
i
++
)
{
cout
<<
t
[
i
]
<<
" "
;
}
cout
<<
endl
;
}
void
bubble_sort
(
int
t
[],
int
rozmiar
)
{
// sortuje zawartość tablicy (układa liczby w kolejności rosnącej)
// stosując zamianę elementów miejscami
int
tmp
;
bool
jeszcze_zle
;
do
{
jeszcze_zle
=
false
;
for
(
int
i
=
1
;
i
<
rozmiar
;
i
++
)
{
if
(
t
[
i
-
1
]
>
t
[
i
])
{
tmp
=
t
[
i
-
1
];
t
[
i
-
1
]
=
t
[
i
];
t
[
i
]
=
tmp
;
jeszcze_zle
=
true
;
}
}
}
while
(
jeszcze_zle
);
}
int
main
()
{
srand
(
time
(
nullptr
));
int
t
[
SIZE
];
wypelnij_losowo
(
t
,
SIZE
,
100
);
cout
<<
"wersja wylosowana:
\n
"
;
wypisz
(
t
,
SIZE
);
bubble_sort
(
t
,
SIZE
);
cout
<<
"wersja posortowania:
\n
"
;
wypisz
(
t
,
SIZE
);
return
0
;
}
20231221/wylosuj_tablice.cpp
0 → 100644
View file @
215f772e
#include <iostream>
using
namespace
std
;
const
int
SIZE
=
20
;
void
wypelnij_losowo
(
int
t
[],
int
rozmiar
,
int
zakres
)
{
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
t
[
i
]
=
rand
()
%
zakres
;
}
}
void
wypisz
(
int
t
[],
int
rozmiar
)
{
for
(
int
i
=
0
;
i
<
rozmiar
;
i
++
)
{
cout
<<
t
[
i
]
<<
" "
;
}
cout
<<
endl
;
}
int
main
()
{
srand
(
time
(
nullptr
));
int
t
[
SIZE
];
wypelnij_losowo
(
t
,
SIZE
,
100
);
wypisz
(
t
,
SIZE
);
return
0
;
}
20231221/zgadywanie.cpp
0 → 100644
View file @
215f772e
#include <iostream>
using
namespace
std
;
/* Zadanie: Program losuje liczbę a użytkownik ma ją zgadnąć, a jeśli nie zgadnie, to program pisze,
czy wpisana liczba jest za duża, czy za mała.
Wczytywanie odpowiedzi ma trwać w pętli tak długo, aż zostanie podana poprawna odp.
Wtedy użytkownik "wygrywa" i wypisujemy gratulacje
*/
int
main
()
{
srand
(
time
(
nullptr
));
int
liczba
=
rand
()
%
1000
;
cout
<<
"Jaką liczbę wylosowałem?
\n
"
;
int
ile_prob
=
1
;
int
odpowiedz
;
cin
>>
odpowiedz
;
while
(
odpowiedz
!=
liczba
)
{
if
(
odpowiedz
<
liczba
)
{
cout
<<
"za mało. podaj większą: "
;
}
else
{
cout
<<
"za dużo. podaj mniejszą: "
;
}
cin
>>
odpowiedz
;
ile_prob
++
;
}
cout
<<
"Gratulacje, udało się w "
<<
ile_prob
<<
" próbie!"
<<
endl
;
return
0
;
}
\ No newline at end of file
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