Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int dlugosc(char tab[]) {
- int i = 0;
- while (*tab != '\0') {
- tab += 1;
- i += 1;
- }
- return i;
- }
- int main() {
- char *slowo1 = new char[100000000];
- char *slowo2 = new char[100000000];
- scanf("%s", slowo1);
- scanf("%s", slowo2);
- char *tab = slowo1;
- int a = dlugosc(slowo2);
- int b = dlugosc(slowo1);
- int wynik = 0;
- for (int i = 0; i < a; i++) {
- if (slowo2[i] == *slowo1) {
- slowo1++;
- if (*slowo1 == '\0')
- {
- wynik = i+1 - b;
- break;
- }
- }
- else slowo1 = tab;
- }
- cout << wynik << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement