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
6096dd89
Commit
6096dd89
authored
Nov 24, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zajęcia 23.11 - palindorm
parent
c672eb5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
+72
-0
min_max.cpp
20231123/min_max.cpp
+29
-0
napis01.cpp
20231123/napis01.cpp
+15
-0
palindrom_v1.cpp
20231123/palindrom_v1.cpp
+28
-0
No files found.
20231123/min_max.cpp
0 → 100644
View file @
6096dd89
#include <iostream>
#include <cstdlib>
#include <ctime>
using
namespace
std
;
const
int
SIZE
=
20
;
int
main
()
{
srand
(
time
(
nullptr
));
// Tworzymy tablicę 20 liczb z zakresu od 0 do 99.
int
t
[
SIZE
];
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
t
[
i
]
=
rand
()
%
100
;
}
// wypisanie tablicy
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
cout
<<
t
[
i
]
<<
", "
;
}
cout
<<
endl
;
// Zadanie: znajdz w tablicy najmniejsza i najwieksza liczbe i je wypisz.
int
max
=
???????
;
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
if
(
t
[
i
]
>
max
)
{
max
=
t
[
i
];
}
}
return
0
;
}
\ No newline at end of file
20231123/napis01.cpp
0 → 100644
View file @
6096dd89
#include <iostream>
using
namespace
std
;
int
main
()
{
cout
<<
"Napisz swój tekst:
\n
"
;
string
napis
;
getline
(
cin
,
napis
);
cout
<<
"Cały tekst: "
<<
napis
<<
endl
;
cout
<<
"Długość tekstu: "
<<
napis
.
length
()
<<
endl
;
cout
<<
"Pierwsza litera: "
<<
napis
[
0
]
<<
endl
;
cout
<<
"Środkowy znak: "
<<
napis
[
napis
.
length
()
/
2
]
<<
endl
;
cout
<<
"Ostatnia litera: "
<<
napis
[
napis
.
length
()
-
1
]
<<
endl
;
return
0
;
}
20231123/palindrom_v1.cpp
0 → 100644
View file @
6096dd89
#include <iostream>
using
namespace
std
;
int
main
()
{
cout
<<
"Napisz swój tekst:
\n
"
;
string
napis
;
getline
(
cin
,
napis
);
bool
czy_jest_ok
=
true
;
for
(
int
i
=
0
;
i
<
napis
.
length
();
i
++
)
{
// cout << napis[i] << " vs " << napis[napis.length()-(i+1)] << endl;
if
(
napis
[
i
]
!=
napis
[
napis
.
length
()
-
(
i
+
1
)])
{
// jeśli gdzieś znak z początku nie zgadza się ze znakiem z końca, tzn że napis nie jest palidromem
czy_jest_ok
=
false
;
}
}
if
(
czy_jest_ok
)
{
cout
<<
"Napis jest palindromem
\n
"
;
}
else
{
cout
<<
"Napis nie jest palindromem, bo odwrotnie wygląda tak:
\n
"
;
for
(
int
i
=
napis
.
length
()
-
1
;
i
>=
0
;
i
--
)
{
cout
<<
napis
[
i
];
}
cout
<<
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