Предмет:
ИнформатикаАвтор:
gabriellegrayАвтор:
belén48Автор:
miss piggyqomgАвтор:
kenyaclyvАвтор:
destineectr5Автор:
ireneo#include <iostream>
#include <string>
using namespace std;
int main()
{
int cnt = 0;
string substr, str;
cin >> substr >> str;
for (size_t i = 0; i < str.length()-substr.length()+1; i++)
{
for (size_t j = 0; j < substr.length(); j++)
{
if (str[i+j] != substr[j])
{
break;
}
else
{
if (j == substr.length() - 1) ++cnt;
}
}
}
cout << cnt;
return 0;
}
Все тесты которые ты написал, отработали.
Автор:
mackenzientpg#include <iostream>
#include <string>
using namespace std;
int main()
{
string str,sub;
int cnt=0;
cout<<"substr: "; cin>>sub;
cout<<"str: "; cin>>str;
int i=0,j=0;
while (i<str.length()) {
while ((str[i]!=sub[j]) && (i<str.length())) i++;
if (i<str.length()) {
while ((str[i]==sub[j]) && (i<str.length()) && (j<sub.length())) {
i++; j++;
}
if (j==sub.length()) cnt++;
j=0;
}
}
cout<<cnt<<endl;
system("pause");
return 0;
}
Автор:
dario89Добавить свой ответ
Предмет:
ОбществознаниеАвтор:
dolcewi43Ответов:
Смотреть
Предмет:
МатематикаАвтор:
gatorgu2sОтветов:
Смотреть