본문 바로가기
프로그래밍

[C++] 명품 c++ 프로그래밍 실습 11장 7번

by 엽기토기 2020. 12. 23.
반응형
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
	ios::left;
	for (int i = 0; i < 4; i++) {
		cout << setw(5) << left<<"dec";
		cout << setw(5) << left<< "hexa";
		cout << setw(5) << left<<"char";
	}
	cout << endl;

	for (int i = 0; i < 4; i++) {
		cout << setw(5) << left << "----";
		cout << setw(5) << left << "----";
		cout << setw(5) << left << "----";
	}
	cout << endl;

	for (int i = 0; i < 128; i ++) {
			cout << setw(5) << dec <<left<< i;
			cout << setw(5) << hex <<left<< i;
			if (isprint(i) == 0) {
				cout << setw(5) << '.';
			}
			else
			cout << setw(5) << left<<(char)i;
			if ((i+1)% 4 == 0) cout << endl;
	}
}

 

반응형