#include <stdlib.h>
#include <iostream>
using namespace std;
int inverse(char *temp,int num) //abcd-> dcba
{
if (temp == NULL)return -1;
//int num = 0;
//num = strlen(temp);
char *p1 = temp;
char *p2 = temp + num - 1;
while (p1 < p2)
{
char a;
a = *p1;
*p1 = *p2;
*p2 = a;
p1++;
p2--;
}
return 0;
}
int cheakinverse(char *temp,char *temp1)
{
if (temp == NULL)return -1;
char *p0 = NULL;
char *p1 = temp;
int cnt = 0;
while (*p1 != 0)
{
p0 = strstr(p1, temp1);
if (p0 != NULL)
{
cnt++;
p1 = p0;
p0 = NULL;
inverse(p1, 4);
p1 = p1 + strlen(temp1);
continue;
}
p1++;
}
return cnt;
}
int main()
{
char temp[256] = "abcde1111abcd2222abcdaqqqq";
//inverse(temp,3);
char a[5] = "abcd";
cout<<cheakinverse(temp,a)<<endl;
cout << temp;
system("pause");
return 0;
}