#include
#include
char input[1024];
int len;
int find_mistake()
{
int i, mistake = 0;
for (i = 0; i < len; i ++)
if (input == '1')
mistake ^= i + 1;
return mistake;
}
int main()
{
int i, mistake = 0;
char info[1024];
int info_pos = 0;
int b = 1;
printf("Enter code: ");
scanf("%s", input);
len = strlen(input);
for (i = 0; i < len; i++)
if (input != '0' && input != '1')
{
printf("Invalid code.\n");
return -1;
}
mistake = find_mistake();
if (mistake)
{
input[mistake - 1] ^= '0' ^ '1';
mistake = find_mistake();
if (mistake)
{
printf("Invalid code.\n");
return -1;
}
}
printf("Fixed code: %s\n", input);
for (i = 0; i < len; i++)
if (i + 1 == b)
b <<= 1;<br> else
info[info_pos++] = input;
info[info_pos] = '\0';
printf("Informational string: %s\n", info);
return 0;
}