Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char a[80], com[80],buff[80];
- printf("enter the string\n");
- scanf("%[^\n]s", a);
- com[0] = 'o';
- com[1] ='\0';
- int i,j,n;
- char last = a[0];
- for (i = 1;a[i] != '\0';i++)
- {
- if(last == a[i])
- {
- buff[0] = a[i];
- buff[1] = a[i];
- for(j=2;a[i-1+j]!='\0';j++)
- {
- buff[j] = a[i-1+j];
- }
- buff[j] = '\0';
- for(j=i+1;buff[j-i-1]!='\0';j++)
- {
- a[j]=buff[j-i-1];
- }
- a[j] = '\0';
- i+=2;
- }
- last = a[i];
- }
- for (n = 0;a[n]!='\0';n++)
- {
- printf("%c", a[n]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment