ImFe's study

객체지향프로그래밍 과제-아스키코드 표 출력(C++) 본문

Programming/C언어 백준 풀이

객체지향프로그래밍 과제-아스키코드 표 출력(C++)

ImFe 2020. 4. 11. 00:10
#include <iomanip>
#include <iostream>

using std::cout;
using namespace std;

int main()
{
	//ASCII 32번부터 126번까지 출력하는 프로그램
	cout <<"                    "<<"ASCII코드를 32번부터 126번까지 출력하는 프로그램";
		cout << "\n";
		cout << "\n";
		cout << "\n";
		cout << "\n";
		cout << "\n";
	for (int i = 32; i < 42; i++)
		cout <<setw(1)<< i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 42; i < 52; i++)
		cout << setw(1) << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 52; i < 62; i++)
		cout << setw(1) << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 62; i < 72; i++)
		cout << setw(1) << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 72; i < 82; i++)
		cout << setw(1) << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 82; i < 92; i++)
		cout << setw(1) << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 92; i < 102; i++)
		cout << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 102; i < 112; i++)
		cout << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 112; i < 122; i++)
		cout << i << ":" << (char)i <<"\t";
	cout << "\n";
	
	for (int i = 122; i < 127; i++)
		cout << i << ":" << (char)i <<"\t";
	cout << "\n";
	


	return 0;

}

동기가 알려준 setw()가 C언어의 %3d같은건줄알고 사용해봤으나 실패..

더 알아봐야겠다

 

Comments