Submission

Status:
PPPPPPPPPP

Score: 100

User: solarsunny

Problemset: แปลงเลขฐาน

Language: c

Time: 0.001 second

Submitted On: 2024-12-20 12:28:29

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int b[100];
int o[100];


int main() {
    int s;
    scanf("%x", &s);


    int t=s;

    int bi=0;
    while(t!=0) {
        b[bi] = t%2;
        bi++;
        t /= 2;
    }

    t=s;
    

    int oi=0;
    while(t!=0) {
        o[oi] = t%8;
        oi++;
        t /= 8;
    }

    for(int i=bi-1; i>=0; i--) {
        printf("%d", b[i]);
    }
    printf("\n");
    for(int i=oi-1; i>=0; i--) {
        printf("%d", o[i]);
    }
    printf("\n");

    return 0;
}