Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int STRP(char *str1, char *str2);
- int STRP(char *str1, char *str2)
- {
- int str1Length = strlen(str1),
- str2Length = strlen(str2);
- for (int i = 0; i < str1Length; i++)
- for (int j = 0; j < str2Length; j++)
- if (str1[i] == str2[j])
- return i;
- return -1;
- }
- void main(void)
- {
- setlocale(LC_ALL, ".1251");
- int result;
- char string1[80], string2[80];
- cout << "Введите строку 1: ";
- cin.getline(string1, 80);
- cout << "Введите строку 2: ";
- cin.getline(string2, 80);
- result = STRP(string1, string2);
- if (result == -1)
- cout << "Строка ни содержит символов второй строки" << endl;
- else
- cout << "Символ найден, позиция = " << result + 1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement