#25515: C


studyfromzhang0809@gmail.com (JHE JIA ZHANG)

School : Queensland University of Technology
ID : 135733
IP address : [111.249.11.93]
Last Login :
2021-06-24 11:17:46
a034. 二進位制轉換 | From: [114.25.42.231] | Post Date : 2021-05-28 14:29

#include <stdio.h>

 

int main(int argc, const char * argv[]) {

    int INPUTNUMBER = 0, i = 0;

    int ans[100] = {0};

    while(scanf("%d",&INPUTNUMBER) != EOF)

    {

        i = 0;

        while(INPUTNUMBER / 2 )

        {

            ans[i] = INPUTNUMBER % 2;

            INPUTNUMBER = INPUTNUMBER / 2;

            i ++;

        }

        ans[i] = INPUTNUMBER;

        while(i >= 0)

        {

            printf("%d",ans[i]);

            ans[i] = 0;

            -- i;

        }

        printf("\n");

    }

    return 0;

}

 
ZeroJudge Forum