Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<conio.h>
- #include<string>
- #include<math.h>
- using namespace std;
- //Korzystając z tablicy znaków wczytać tekst(do 200 znaków), a następnie wczytać poszukiwany tekst(do 15 znaków).
- //Należy wypisać ile razy poszukiwany tekst występuje we wczytanym tekście nie uwzględniając wielkości liter - tekst pisany małymi i dużymi literami to ten sam tekst!
- int main()
- {
- char tab1[200];
- char tab2[15];
- cout << "podaj tekst do przeszukania "<<endl;
- cin.getline(tab1, 200);
- cout << "podaj tekst do wyszukania" << endl;
- cin.getline(tab2, 15);
- int j,caly=0,z=0,a=strlen(tab1),b=strlen(tab2);
- for (int i = 0; i < a; i++)
- {
- z = 0;
- if (tab2[0] == tab1[i])
- {
- for ( j = 1; j < b; j++)
- {
- if (tab2[j] == tab1[i + j])
- {
- z++;
- }
- else
- break;
- }
- }
- if (z == b)
- caly++;
- }
- cout << caly;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement