Name: RandomJavaGuy 2013-10-19 17:23
Hello. i am trying to write a simple program in c that will read field of chars(aaabbbaaa) and than an interval and than it will find out the number of neighboring same chars in the interval and print it.
char field[256];
scanf("%s" , field);
int start;
int end;
scanf("%d %d", start, end);
int neighbors = 0;
for(int i=start;i<end;i++)
{
if(field[i]==field[i+1])
{
neighbors++;
}
}
printf("%d", neighbors);
char field[256];
scanf("%s" , field);
int start;
int end;
scanf("%d %d", start, end);
int neighbors = 0;
for(int i=start;i<end;i++)
{
if(field[i]==field[i+1])
{
neighbors++;
}
}
printf("%d", neighbors);