Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "Введи ваше имя :";
  8. char name [1000];
  9. cin.getline(name, 1000);
  10. cout << "Введи вашу фамилию :";
  11. char surname [1000];
  12. cin.getline(surname, 1000);
  13. cout << "Введи любое предложение( желательно с вашем именем):";
  14. char str [1000];
  15. cin.getline(str, 1000);
  16. int i=0;
  17. int j=0;
  18. int y=0;
  19. int range1=0;
  20. int range2=0;
  21. int found1=0;
  22. int found2=0;
  23. int probel=0;
  24. while (name[j] != 0)
  25. {
  26. j++;
  27. }
  28. while (surname[y] != 0)
  29. {
  30. y++;
  31. }
  32. while (str[i] != 0)
  33. {
  34. if (str[i] == name[range1])
  35. {
  36. range1++;
  37. found1++;
  38. }
  39. else
  40. {
  41. range1=0;
  42. found1=0;
  43. }
  44. if (str[i] == name[range2])
  45. {
  46. range2++;
  47. found2++;
  48. }
  49. else
  50. {
  51. range2=0;
  52. found2=0;
  53. }
  54. if (found1 == j)
  55. {
  56. while(str[i+1] == surname[1])
  57. {
  58. if (str[i+3] == surname[2])
  59. {
  60. probel=1;
  61. }
  62. }
  63. }
  64. if ((found1 == j) && (found2 == y ))
  65. {
  66. found1=1;
  67. break;
  68. }
  69. i++;
  70. }
  71. cout << "probel:" << probel << endl;
  72. cout << "found:" << found1 << endl;
  73. i = j;
  74. if(str[i] == ' ')
  75. {
  76. if(probel == 1)
  77. {
  78. found1=3;
  79. cout << "found1:" << found1 << endl;
  80. }
  81. }
  82. cout << "found2:" << found1 << endl;
  83. if (found1==3)
  84. {
  85. cout << "В строке есть ваше имя :)";
  86. }
  87. else
  88. {
  89. cout << "В строке нет вашего имени :(";
  90.  
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement