Skip to content

Commit 57cf71a

Browse files
authored
Merge pull request gzc426#16 from wyfdream/master
hhhh
2 parents 9161f6b + 049c640 commit 57cf71a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

2019.11.24/超能炸弹人.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
#include<iostream>
2-
using namespace std;
3-
int main()
4-
{
5-
cout<<"hello!";
6-
return 0;
7-
}
1+
class Solution {
2+
public:
3+
int strStr(string haystack, string needle) {
4+
int len1=haystack.size(),len2=needle.size();
5+
if(len2==0)
6+
return 0;
7+
for(int i=0;i<=len1-len2;i++)
8+
{
9+
for(int j=0;j<len2;j++)
10+
{
11+
if(haystack[i+j]!=needle[j])
12+
{
13+
break;
14+
}
15+
if(j==(len2-1))
16+
return i;
17+
}
18+
}
19+
return -1;
20+
21+
}
22+
};

0 commit comments

Comments
 (0)