Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- char str[100], output[100], buffer;
- int len, len2;
- gets(str);
- len = strlen(str);
- len2 = 0;
- buffer = 0;
- for(int i = len - 1, shift = 0; i >= 0; --i) {
- if(str[i] == '.') {
- shift = 0;
- output[len2++] = buffer;
- buffer = 0;
- continue;
- }
- if(str[i] == '1')
- buffer += (1 << shift);
- shift++;
- }
- output[len2++] = buffer;
- output[len2] = '\0';
- for(int i = len2 - 1; i >= 0; --i)
- printf("%c", output[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement