C++ 数组操作示例:元素递增并计算对角线乘积
#include
int f(int a[][3], int row, int col);
int main() { int a[][3] = { {0, 1, 2}, {3, 4, 5}, {6, 7, 8} }; cout << f(a, 3, 3) << endl; system("pause"); return 0; }
int f(int a[][3], int row, int col) { int i, j, t = 1; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { a[i][j]++; if (i == j) { t *= a[i][j]; } } } return t; }
原文地址: https://www.cveoy.top/t/topic/oX7g 著作权归作者所有。请勿转载和采集!