#include // 查找数组中的元素并替换为特定值 void findReplace(int rows, int cols, int (*p)[cols], int oval, int nval) { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (*(*(p + i) + j) == oval) *(*(p + i) + j) = nval; } } } int main() { int a[3][3] = {1, 2, 3, 4, 1, 6, 1, 8, 9}; int(*q)[3] = a; findReplace(3, 3, q, 1, 9); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("%d ", a[i][j]); } printf("\n"); } }