Advertisement
dariahinz

mamo

Mar 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int dlugosc(char tab[]) {
  5. int i = 0;
  6. while (*tab != '\0') {
  7. tab += 1;
  8. i += 1;
  9. }
  10. return i;
  11. }
  12.  
  13. int main() {
  14. char *slowo1 = new char[100000000];
  15. char *slowo2 = new char[100000000];
  16. scanf("%s", slowo1);
  17. scanf("%s", slowo2);
  18.  
  19.  
  20. char *tab = slowo1;
  21. int a = dlugosc(slowo2);
  22. int b = dlugosc(slowo1);
  23. int wynik = 0;
  24. for (int i = 0; i < a; i++) {
  25. if (slowo2[i] == *slowo1) {
  26. slowo1++;
  27. if (*slowo1 == '\0')
  28. {
  29. wynik = i+1 - b;
  30. break;
  31. }
  32. }
  33. else slowo1 = tab;
  34. }
  35.  
  36. cout << wynik << endl;
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement