ImFe's study

객체지향 프로그래밍 과제(rep3) 본문

Programming/C언어 백준 풀이

객체지향 프로그래밍 과제(rep3)

ImFe 2020. 4. 22. 17:43
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int x;
	int y;
	int z;
	
	cout << setw(62) << "구구단 출력\n";
	cout << setw(62) << "===========\n";
	cout << "\n";
	cout << "  ";

	for (x = 2; x < 6; x++)
	{
		cout << setw(19) << x << " 단";
	}
	cout << "\n";
	cout <<"                 ---------------------------------------------------------------------------";
	for (y = 1; y < 10; y++)
	{
		cout << endl << setw(19);
		for (z = 2; z < 6; z++)
		{
			cout << z << "*" << y << "=" << setw(3) << z * y << setw(16);

		}
	}


	cout << "\n\n\n\n";
	cout << "  ";
	for (x = 6; x < 10; x++)
	{
		cout << setw(19) << x << " 단";
	}
	cout << "\n";
	cout << "                 ---------------------------------------------------------------------------";
	for (y = 1; y < 10; y++)
	{
		cout << endl << setw(19);
		for (z = 6; z < 10; z++)
		{
			cout << z << "*" << y << "=" << setw(3) << z * y << setw(16);

		}
	}

	return 0;
}

 

칸맞추는것좀 안했으면 좋겠다.

 

1.setw()는 띄어쓰기가 아니였다.

2.setw(n)을 했을때 문자열의 크기가 n보다 크면 의미가 없다.

Comments