코드
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
int main()
{
int num[5][5] = { 0, };
int c;
while (1)
{
cout << "1, 2, 3, 4 : ";
cin >> c;
int cnt = 0;
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
++cnt;
switch (c)
{
case 1:
num[i][j] = cnt;
break;
case 2:
num[j][(5 - 1) - i] = cnt;
break;
case 3:
num[(5 - 1) - i][j] = cnt;
break;
case 4:
num[(5 - 1) - j][i] = cnt;
break;
}
}
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
cout << setw(4) << num[i][j];
}
cout << endl;
}
}
}
결과값
0 댓글