两种奇奇怪怪的方法:
法1:
#include<stdio.h>
int main()
{
int arr[5][5] = { 0 };
int n = 0, m = 0, x = 0, y = 0,tmp=0;
int* p = (int*)arr;
scanf("%d %d", &n, &m);
for (int i = 0; i < n * m; i++)
{
scanf("%d", p + i);
}
scanf("%d %d", &x, &y);
tmp = (x - 1)*m+y-1;
printf("%d\n",*(p+tmp));
return 0;
}
法2:
#include<stdio.h>
int main()
{
int arr[5][5] = { 0 };
int n = 0, m = 0, x = 0, y = 0;
int* p = (int*)arr;
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
scanf("%d", &arr[i][j]);
}
scanf("%d %d", &x, &y);
printf("%d\n", arr[x - 1][y - 1]);
return 0;
}