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?

[例題の為の例題]入力'1','2','A','B'を16進12ABにせよ!!!(オンラインコンパイラ)

Posted at

いろいろ注意

  • 過去ログを見よ!!!

プログラム

  • オンラインコンパイラ


//0 1 2 3 4 5 6 7 8 9 A B C D E F
char t[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //00
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //10
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //20
0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, //30

0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, //40
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //50
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //60
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //70

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //80
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //90
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //A0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //B0

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //C0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //D0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //E0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0  //F0
};

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    unsigned char p[4];
    
    p[0] = '1';
    p[1] = '2';
    p[2] = 'A';
    p[3] = 'B';


    int g = 0;
    for(int i=0;i<4;i++){
        
       int a = p[i];
       g = (g << 4) + t[a];
       
    }  //for 
    
    printf("%X\n",g);
    
}  //main




12AB

0
0
2

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?