Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: samsenpisardmoo26
Problemset: เลขดวง
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-06 23:03:36
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[8][9];
for(int i=0; i<8; i++)
{
for(int j=0; j<9; j++)
{
arr[i][j] = 0;
}
}
int d;
cin >> d;
int cnt = 1;
int n;
cin >> n;
int h;
cin >> h;
for(int i=n; i<8; i++)
{
arr[1][i] = cnt;
cnt++;
}
for(int i=2; i<7; i++)
{
for(int j=1; j<8; j++)
{
if(cnt > d) break;
arr[i][j] = cnt;
cnt++;
}
}
for(int i=0; i<8; i++)
{
for(int j=0; j<9; j++)
{
cout << arr[i][j] << " ";
}
cout << "\n";
}
cout << "\n";
for(int i=1; i<7; i++)
{
for(int j=1; j<8; j++)
{
if(arr[i][j] == h)
{
cout << arr[i][j-1] << "\n";
cout << arr[i-1][j] << "\n";
cout << arr[i+1][j] << "\n";
cout << arr[i][j+1] << "\n";
cout << arr[i][j-1] + arr[i-1][j] + arr[i+1][j] + arr[i][j+1];
}
}
}
}