Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Введи ваше имя :";
- char name [1000];
- cin.getline(name, 1000);
- cout << "Введи вашу фамилию :";
- char surname [1000];
- cin.getline(surname, 1000);
- cout << "Введи любое предложение( желательно с вашем именем):";
- char str [1000];
- cin.getline(str, 1000);
- int i=0;
- int j=0;
- int y=0;
- int range1=0;
- int range2=0;
- int found1=0;
- int found2=0;
- int probel=0;
- while (name[j] != 0)
- {
- j++;
- }
- while (surname[y] != 0)
- {
- y++;
- }
- while (str[i] != 0)
- {
- if (str[i] == name[range1])
- {
- range1++;
- found1++;
- }
- else
- {
- range1=0;
- found1=0;
- }
- if (str[i] == name[range2])
- {
- range2++;
- found2++;
- }
- else
- {
- range2=0;
- found2=0;
- }
- if (found1 == j)
- {
- while(str[i+1] == surname[1])
- {
- if (str[i+3] == surname[2])
- {
- probel=1;
- }
- }
- }
- if ((found1 == j) && (found2 == y ))
- {
- found1=1;
- break;
- }
- i++;
- }
- cout << "probel:" << probel << endl;
- cout << "found:" << found1 << endl;
- i = j;
- if(str[i] == ' ')
- {
- if(probel == 1)
- {
- found1=3;
- cout << "found1:" << found1 << endl;
- }
- }
- cout << "found2:" << found1 << endl;
- if (found1==3)
- {
- cout << "В строке есть ваше имя :)";
- }
- else
- {
- cout << "В строке нет вашего имени :(";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement