Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char buff1[61];
- char buff2[61];
- void modify(char* ptr)
- {
- while (*(ptr + 1) != *ptr && *(ptr + 1) != '\0')
- {
- *(ptr + 1) = *ptr;
- ptr++;
- }
- }
- void better_modify(char* ptr)
- {
- char first = ptr[0];
- while (*ptr != '\0' && *(ptr + 1) != '\0')
- {
- while (*ptr == first)
- {
- ptr++;
- }
- while (*ptr != first && *(ptr + 1) != '\0')
- {
- ptr++;
- }
- modify(ptr);
- }
- }
- int input(int index)
- {
- printf("\n\n==== INPUT ====\n\n");
- if (index == 1)
- {
- gets_s(buff1, 61);
- if (buff1[0] == '\0')
- {
- return 3;
- }
- return 1;
- }
- if (index == 2)
- {
- gets_s(buff2, 61);
- if (buff2[0] == '\0')
- {
- return 3;
- }
- return 2;
- }
- }
- int output(int index)
- {
- printf("\n\n==== OUTPUT ====\n\n");
- if (index == 1)
- {
- puts(buff1);
- return 2;
- }
- if (index == 2)
- {
- puts(buff2);
- return 1;
- }
- }
- void main()
- {
- int check = input(1);
- while (check != 3)
- {
- if(check==1)
- {
- modify(&buff1);
- better_modify(&buff1);
- }
- if(check==2)
- {
- modify(&buff2);
- better_modify(&buff2);
- }
- check = output(check);
- check = input(check);
- }
- system("pause");
- }
Add Comment
Please, Sign In to add comment