Professional Documents
Culture Documents
h>
#include<string.h>
#include<math.h>
else if(ara2[i]=='\0')
{
return 2;}
else if(ara1[i]>ara2[i])
{
return 2;}
else if(ara1[i]<ara2[i])
{
return 3;}
i++;
}
}
char str[1000005];
char word[1000005][5];
char word2[1000005][5];
int serial[1000005];
scopy(word[coun],word2[l+i]);
coun++;
i++;
}
else if(scompare(word2[l+i],word2[m+j+1])==2)
{
scopy(word[coun],word2[m+j+1]);
coun++;
j++;
}
sorting(l,m,r,i,j,coun);
}
int main()
{
scanf("%[^\n]s",str);
int i,j,c=0;
int n=slength(str);
if(n>=4)
{
word[c][0]=word2[c][0]=str[0];
word[c][1]=word2[c][1]=str[1];
word[c][2]=word2[c][2]=str[2];
word[c][3]=word2[c][3]=str[3];
word[c][4]=word2[c][4]='\0';
c++;
}
for(i=4; i<n;i++)
{
word[c][0]=word2[c][0]=word[c-1][1];
word[c][1]=word2[c][1]=word[c-1][2];
word[c][2]=word2[c][2]=word[c-1][3];
word[c][3]=word2[c][3]=str[i];
word[c][4]=word2[c][4]='\0';
c++;
int l=0,r=c-1;
merged(l,r);
//if length of str is less than 4,c will be 0;
if(c==0)
{
printf("\n");
}
else
{
int maxc=1;
int f1=0;// f1 is the frequency of the string that occurs the highest time
serial[f1]=0;//serial keeps the index of the strings that occur the highest
time
for(i=0;i<c-1;i=i+1)
{
if(scompare(word[i],word[i+1])==1)
{
cnt++;
}
else
{
if(cnt==maxc)
{
serial[f1]=i;
f1++;
}
else if(cnt>maxc)
{
maxc=cnt;
serial[0]=i;
f1=1;
}
cnt=1;
}
}
//check for the last of the loop which was not checked
if(cnt==maxc)
{
serial[f1]=i;
f1++;
cnt=1;
}
else if(cnt>maxc)
{
maxc=cnt;
cnt=1;
serial[0]=i;
f1=1;
}
for(i=0;i<f1;i=i+1)
{
printf("%s\n",word[ serial[i] ]);
}
}
return 0;
}