矩阵位置 题解:
#include<iostream>
using namespace std;
int main() {
int array[3][3] = {
{1,2,3},
{4,5,6},
{7,8,9},
};
int x;
while (cin >> x) {
for (int i = 0; i < 3; i ++) {
for (int j = 0; j < 3; j ++) {
if (array[i][j] == x) {
cout << i + 1 << ' ' << j + 1 << endl;
}
}
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发