C++/Foundation

007. 구구단을 출력하시오

페프 2021. 3. 16. 06:32

구구단을 출력해 보았다.

for 반복문을 이용해 2x1,3x1,4x,1 다음줄엔 2x2,3,x2,4x2가 출력되게 만들었다.

 

#include <iostream>
using namespace std;

int main() {


	cout << "구구단!" << endl;
	for (int i = 1; i < 9; i++){
		for (int j = 2; j < 9; j++)
			cout << j << "x" << i << "=" << j*i << '\t';
		cout << endl;
	}
}