//program to find the maximum run count of a character
#include<stdio.h>
int main()
{
int count = 0, count_max = 0;
char ch[100],s;
int i=0;
gets(ch);
while(ch[i]!='\0')
{
s = ch[i];
while(ch[i]==s)
{
count++;
i++;
}
if(count_max<count)
{
count_max = count;
count = 0;
}
}
printf("MAX RUN = %d\n",count_max);
return 0;
}
#include<stdio.h>
int main()
{
int count = 0, count_max = 0;
char ch[100],s;
int i=0;
gets(ch);
while(ch[i]!='\0')
{
s = ch[i];
while(ch[i]==s)
{
count++;
i++;
}
if(count_max<count)
{
count_max = count;
count = 0;
}
}
printf("MAX RUN = %d\n",count_max);
return 0;
}
No comments:
Post a Comment