Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string velika_rec, mala_rec;
- cin >> velika_rec >> mala_rec;
- int mesto = -1;
- int poklapanje = 0;
- bool podniska = false;
- int i = 0;
- while (podniska == false) {
- poklapanje = 0;
- if (mala_rec[0] == velika_rec[i]) {
- poklapanje = 1;
- for (int j = 1; j < mala_rec.size(); j++) {
- if (mala_rec[j] == velika_rec[i + j]) {
- poklapanje++;
- }
- }
- if (poklapanje == mala_rec.size()) {
- mesto = i;
- podniska = true;
- }
- else {
- mesto = -1;
- }
- }
- i++;
- if (i == velika_rec.size()-1) {
- podniska = true;
- }
- }
- cout << mesto;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement