[C++] 8진수, 10진수, 16진수 형태로 출력하기

[C++] 8진수, 10진수, 16진수 형태로 출력하기

유유코
커버 [C++] 8진수, 10진수, 16진수 형태로 출력하기

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
 
int main(){
    int n;
    
    cout << "10진수 정수 입력: ";
    cin >> n;
    
    cout << "8진수: "<< oct << n << endl;
    cout << "10진수: "<< dec << n << endl;
    cout << "16진수: "<< hex << n << endl;
    cout << "16진수(대문자): "<< uppercase << hex << n << endl;
}
 
 
출처: https://neos35.tistory.com/2 [컴공대생 mr.ko]
 

8진수 : oct

10진수 : dec

16진수 : hex

16진수 대문자 출력이 필요한 경우 hex 함수 앞에 uppercase 

  • 유유코
    토픽 0  /  봤어요 0

댓글

댓글 본문