

Wyszukiwanie wzorca w tekscie C++
Presentation
•
Computers
•
9th - 12th Grade
•
Practice Problem
•
Hard
Ewelina Kamińska
Used 1+ times
FREE Resource
6 Slides • 5 Questions
1
Wyszukiwanie wzorca w tekście
C++
2
Podstawowe operacje na napisach
Napis to ciąg znaków. Mogą na niego składać się litery, cyfry i inne znaki np. spacja.
W języku C++ napisy oznacza się podwójnym cudzysłowem(" "), a deklaruje jako typ string np. string a="programowanie";
Pojedyncze znaki(cyfry, małe i wielkie litery, znaki interpunkcyjne) deklaruje się jako zmienną typu char i zapisuje się w pojedynczych cudzysłowach- apostrofach ( ' ' ) np. char a="P";
3
Multiple Choice
Zaznacz poprawnie zadeklarowane zmienne
string z="zzz";
char z="zzz";
string z='zzz';
char z='z';
4
Napisy można łączyć ze sobą – jest to tzw. konkatenacja.
W C++ ciągi znaków dodaje się za pomocą znaku + np.
string a="informatyka";
string b="i";
string c="programowanie";
cout<<a+b+c <<endl;
Wypisze nam: informatykaiprogramowanie
5
Multiple Select
Który zapis wypisze nam tekst:A B C
string x="A";
string y="B";
string z="C";
cout<<A+" "+B+" "+C <<endl;
string x="A";
string y="B";
string z="C";
cout<<x+" "+y+" "+z <<endl;
string x="A";
string y="B";
string z="C";
cout<<x+' '+y+' ' +z <<endl;
string x="A";
string y="B";
string z="C";
cout<<a+" "+b+" "+c <<endl;
6
Wyznaczanie długości napisu
Wynikiem metody size() jest długość ciągu znaków podanego jako jej argument np.
string t="wakacje";
cout<<t.size()<<endl;
Wypisze nam:7 ponieważ z tylu znaków składa się napis "wakacje".
7
Multiple Choice
Co wypisze poniższy program:
string t="wakacje";
string g="nad";
string h="morzem";
string x= t+" "+g+" "+h;
cout<<x.size();
16
17
18
19
8
Analizowanie napisu
Do pojedynczego znaku napisu należy odwoływać się przez indeks. Jego wartość umieszczona po nazwie zmiennej w nawiasie kwadratowym i liczona od zera, wskazuje odpowiedni znak.
Przykład:
string napis="programowanie";
cout<<napis[12];
Wypisze nam: 'e' ponieważ 12 znakiem w napisie "programowanie" jest litera 'e'.
9
Multiple Choice
Co wypisze nam poniższy program:
string text="programowanie";
cout<<text[0];
Pojawi się błąd
e
0
p
10
Analiza napisu za pomocą pętli for
Analizę napisu litera po literze można wykonać za pomocą pętli for.
-Na początku zmiennej sterującej i przypisywana jest wartość 0 (i=0),
-W każdym obrocie pętli jej wartość jest zwiększana o 1 (i++),
-Pętla wykonywana jest tak długo, jak długo warunek i<napis.size() jest spełniony
Przykład:
int i;
string napis="ola";
for (i=0; i<napis.size(); i++)
cout<<napis[i] <<endl;
11
Multiple Choice
Który zapis wypisze nam na ekranie:
h
e
j
int i;
string napis="hej";
for (i=0; i<text.size(); i++)
cout<<text[i] <<endl;
int i;
string text="hej";
for (i=0; i<text.size(); i++)
cout<<text[i] <<endl;
int i;
string text="hej";
for (i=1; i<text.size(); i++)
cout<<text[i] <<endl;
int i;
string text="hej";
for (i=0; i<text.size(); i++)
cout<<napis[i] <<endl;
Wyszukiwanie wzorca w tekście
C++
Show answer
Auto Play
Slide 1 / 11
SLIDE
Similar Resources on Wayground
10 questions
Verbs that change meaning in the preterite
Presentation
•
9th - 12th Grade
10 questions
Adobe Photoshop Shortcut Keys
Presentation
•
9th - 12th Grade
9 questions
Project 2 Checkpoint 3:
Presentation
•
9th - 12th Grade
10 questions
Python Data Types
Presentation
•
9th - 12th Grade
11 questions
Revising & Editing
Presentation
•
9th - 12th Grade
11 questions
Commas with Conjunctions and Introductory Elements
Presentation
•
9th - 12th Grade
10 questions
Solving Systems by Substitution
Presentation
•
8th - 12th Grade
10 questions
Estructura 4.2: stem changing verbs
Presentation
•
10th - 12th Grade
Popular Resources on Wayground
6 questions
Secondary Safety Quiz
Presentation
•
9th - 12th Grade
10 questions
Afterschool Activities & Sports
Quiz
•
6th - 8th Grade
19 questions
ROAR Week 2026
Quiz
•
9th - 12th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
15 questions
Cool Tool:Chromebook
Quiz
•
6th - 8th Grade
22 questions
would you rather
Quiz
•
3rd - 11th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
Discover more resources for Computers
20 questions
Early Computing
Quiz
•
7th - 12th Grade
10 questions
Exploring the Parts of a Computer
Interactive video
•
6th - 10th Grade
10 questions
Navigating Digital Citizenship and Online Safety
Interactive video
•
6th - 10th Grade
20 questions
Binary Numbers
Quiz
•
11th Grade
10 questions
Mastering Proper Keyboarding Techniques
Interactive video
•
6th - 10th Grade