Skip to content

Instantly share code, notes, and snippets.

@nagy3n
Created August 10, 2015 21:35
Show Gist options
  • Save nagy3n/41a561029184218c72cd to your computer and use it in GitHub Desktop.
Save nagy3n/41a561029184218c72cd to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
int main()
{
char MESSAGE[100];
fgets(MESSAGE,100,stdin);
int prebit=-1;
int currbit,i,j;
// Write an action using printf(). DON'T FORGET THE TRAILING \n
// To debug: fprintf(stderr, "Debug messages...\n");
for(i=0;i<strlen(MESSAGE)-1;i++)
{
for(j=6;j>=0;j--)
{
currbit=MESSAGE[i]>>j;
currbit&=0x01;
if(prebit==-1)
{
if(currbit==1)
printf("0 0");
else
printf("00 0");
}
else
{
if(currbit==prebit)
{
printf("0");
}
else if(currbit==1)
{
printf(" 0 0");
}
else if(currbit==0)
{
printf(" 00 0");
}
}
prebit=currbit;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment