Enter a string that matches the contiguous string in the string, and the number of consecutive occurrences is equal
such as input AABBCC, ABC, FABC, AABC, AABBC
Output yes or no, respectively
#include <stdio.h>
#include <string.h>
void Main ()
{
/*
Idea: Enter a string array A, define an array of b[3]={1,0,0} (which is intended to be the default first one that does not need to match)
*/
Char a[]={' f ', ' a ', ' a ', ' a ', ' B ', ' d ', ' C '};
Int b[3]={1,0,0};
int i = 0;
int f = 0;
int g = 0;
int h = 1;
printf ("a===%d\n", sizeof (a));
for (i = 1; i< sizeof (a); i++)
{
printf ("i====%d\n", I);
If a[i-1] = = A[i], the default from a[0] = = a[1], equal to add one, equivalent to a[0]= ' a ' = = a[1]= ' A '
if (a[i-1] = = A[i]) {
B[g] = ++h;
printf ("b[%d]=%d\n", G,b[g]);
}
///Here you only need to determine the unequal
if ((a[i-1]! = A[i]) && (a[i-1]-a[i] = = 1)) {//&& a[i]-a[i+1] = 1
if (a[i-1]- A[i] = =-1) {
H = 1;
g = g+1;
B[g] = h;
}else{
if (g==0) {
B[0] = 1;
B[1] = 0;
B[2] = 0;
}
if (g = = 1) {
B[0] = b[1];
B[1] = 0;
B[2] = 0;
}
if (g = = 2) {
B[0] = b[2];
B[1] = 0;
B[2] = 0;
}
h = 1;
g = 0;
}
}
printf ("%d\n", b[0]);
printf ("%d\n", b[1]);
printf ("%d\n", b[2]);
printf ("-----------------------------\ n");
if (B[0] >= b[1] && b[1]== b[2] && b[2]>=1) {
printf ("yes\n");
Break
}
}
}
C language AABBCC, ABC, FABC, AABC