0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[例題の為の例題]kの値を16進で表示せよ!!!(四桁)(オンラインコンパイラ)

Last updated at Posted at 2025-10-01

いろいろ注意

  • 過去ログを見よ!!!
  • arduinoでの予定は、未定
  • シフトパターンは、命題が0x8000を超えない0x1234だから正しい
  • シフトパターンは、オンラインコンパイラは、64ビットなので正しい
  • シフト警察、まいったか!!!(勝った!!!

目的

4ビットづつに分けて変換して表示

プログラム

オンラインコンパイラpaiza



#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char *b = "0123456789ABCDEF";  //16進の変換テーブル

    int k = 0x1234;  //入力値

    putchar(b[k >> 12       ]);  //上位4ビットを表示
    putchar(b[k >>  8 & 0x0f]);  //12ビット目から4ビット
    putchar(b[k >>  4 & 0x0f]);  //8ビット目から4ビット
    putchar(b[k       & 0x0f]);  //下位4ビットを表示
    putchar('\n');
}  //main




1234

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?