编程问题,如图:

来源:百度知道 编辑:UC知道 时间:2024/05/27 04:52:45
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
设“1”的坐标为(0,0) “7”的坐标为(-1,-1) 编写一个小程序,使程 序做到输入坐标(X,Y)之后显示出相应的数字。
最好是用c++编的

#include <stdio.h>

int main()
{
static int array[4][4] = {{7,8,9,10},{6,1,2,11},{5,4,3,12},{16,15,14,13}};
int i,j;
while (1) {
printf("Input (x,y):");
scanf("%d,%d", &i,&j);
if (i<-1||j<-1||i>2||j>2) break;
printf("At (%d,%d)", i++,j++);
printf(" is %d.\n", array[i][j]);
}
return 0;
}