a047: Decimal to Binary 十進制轉二進制
標籤 : 陣列,迴圈
通過比率 : 95% (18 人 / 19 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2019-04-09 08:55

內容

Write a program which converts each input decimal number into the corresponding 8-bit binary number. If the input number is negative, please use two’s complement notation.

撰寫一個程式,使用者輸入一個整數,印出8位元的二進制表示。如果輸入為負數,則以二補數表示。

輸入說明

In the first line, input a positive integer number n (n50), and in the following lines, input n integer numbers with each range between -128~127.

首先輸入一個正整數 n (n 50) ,表示接下來有 n 筆測資。每筆測資輸入數個整數,介於-128~127之間。

輸出說明

Show the corresponding binary number in length of 8 bits. Please print a cartridge return at the end of each output line.

以8位元的二進制顯示,最後必須有換行字元。

範例輸入
2
15
-2
範例輸出
00001111
11111110
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 1.0s , <1K
隱藏 測資點#1 (50%): 1.0s , <1K
提示 :
標籤:
陣列,迴圈
出處:
ITSA_51th [編輯 :
shengZJ (shengZJ)
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」