Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <memory.h>
- #include <string.h>
- char t[2][2][2] = {'0','1','2','3','4','5','6','7'};
- #define z(s,n) (s[n]=='0')?0:1
- #define B(s) t[z(s,0)][z(s,1)][z(s,2)]
- int main(void)
- {
- FILE *f;long l,a;char *b,*n;int i,j=0;
- f=fopen("i","r");
- fseek(f,0,SEEK_END);
- l=ftell(f);
- fseek(f,0,SEEK_SET);
- b=calloc(1,l+1);
- a=((l-1)/3)+((((l-1)%3)>0)?1:0);
- n=calloc(1,a+1);
- fgets(b,l,f);
- fclose(f);
- n[a] = 0;
- for(i=l-4;i>-1;i-=3)
- {
- n[(a-1)-(j++)]=B((&b[i]));
- if(i>0)b[i] = 0;
- }
- if(i==-2)n[0]=t[0][0][z(b,0)];
- if(i==-1)n[0]=t[0][z(b,1)][z(b,0)];
- f=fopen("o","w");
- fputs(n,f);
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement