nihonium
/
mipt_clang
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

83 lines
1.2 KiB
C

3 years ago
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXLEN 4000001
int main() {
char x;
char* res = (char*)calloc(MAXLEN, sizeof(char));
char buf[5] = "";
int i, len;
len = 0;
while (((x = getchar()) != '\n' ) && (x != EOF)) {
switch (x) {
case '0':
strcpy(buf, "0000");
break;
case '1':
strcpy(buf, "0001");
break;
case '2':
strcpy(buf, "0010");
break;
case '3':
strcpy(buf, "0011");
break;
case '4':
strcpy(buf, "0100");
break;
case '5':
strcpy(buf, "0101");
break;
case '6':
strcpy(buf, "0110");
break;
case '7':
strcpy(buf, "0111");
break;
case '8':
strcpy(buf, "1000");
break;
case '9':
strcpy(buf, "1001");
break;
case 'A':
strcpy(buf, "1010");
break;
case 'B':
strcpy(buf, "1011");
break;
case 'C':
strcpy(buf, "1100");
break;
case 'D':
strcpy(buf, "1101");
break;
case 'E':
strcpy(buf, "1110");
break;
case 'F':
strcpy(buf, "1111");
break;
}
for (i = 0; i < 4; ++i) {
res[len++] = buf[i];
}
}
for (i = 0; res[i] == '0'; ++i);
if (i == len) {
printf("0\n");
free(res);
return 0;
}
printf("%s\n", res+i);
free(res);
return 0;
}