Advertisement
Filip13

podniska

Nov 9th, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. string velika_rec, mala_rec;
  7. cin >> velika_rec >> mala_rec;
  8. int mesto = -1;
  9. int poklapanje = 0;
  10. bool podniska = false;
  11. int i = 0;
  12.  
  13. while (podniska == false) {
  14.  
  15. poklapanje = 0;
  16. if (mala_rec[0] == velika_rec[i]) {
  17. poklapanje = 1;
  18. for (int j = 1; j < mala_rec.size(); j++) {
  19. if (mala_rec[j] == velika_rec[i + j]) {
  20. poklapanje++;
  21. }
  22.  
  23. }
  24. if (poklapanje == mala_rec.size()) {
  25. mesto = i;
  26. podniska = true;
  27. }
  28.  
  29.  
  30. else {
  31. mesto = -1;
  32. }
  33.  
  34. }
  35. i++;
  36.  
  37. if (i == velika_rec.size()-1) {
  38. podniska = true;
  39.  
  40. }
  41.  
  42.  
  43. }
  44.  
  45. cout << mesto;
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement