for 문 연습(여러가지 구구단 출력하기)

2중 for 문으로 만들기





















for (int i = 1; i < 10 ; i++)
{
cout << i << "단\t\t" << i + 1 << "단\t\t" << i + 2 << "단" << endl;

for (int j = 1; j < 10; j++)
{

cout << i << " * " << j << " = " << i * j <<  "\t" << i + 1 << " * " << j << " = " << (i + 1) * j << "\t" << i + 2 << " * " << j << " = " << (i + 2) * j << endl;

}
cout << endl;
i = i + 2;
}
cout << "3 x 3 구구단 코드------------------------------------------------------------" <<endl;
cout << "1단 2단 3단------------------------------------------------------------------" <<endl;
cout << "4단 5단 6단------------------------------------------------------------------" <<endl;
cout << "7단 8단 9단------------------------------------------------------------------" << endl << endl << endl;










for (int i = 1; i < 4; i++)
{
cout << i << "단\t\t" << i + 3 << "단\t\t" << i + 3 + 3  << "단\t\t" << endl;

for (int j = 1; j < 10; j++)
{

cout << i << " * " << j << " = " << i * j << "\t" << i + 3 << " * " << j << " = " << (i + 3) * j << "\t" << i + 3 + 3 << " * " << j << " = " << (i + 3 + 3) * j << endl;
}
cout << endl;
}
cout << "3 x 3 구구단 코드------------------------------------------------------------" << endl;
cout << "1단 4단 7단------------------------------------------------------------------" << endl;
cout << "2단 5단 8단------------------------------------------------------------------" << endl;
cout << "3단 6단 9단------------------------------------------------------------------" << endl << endl << endl;


댓글