时间:2021-06-13 08:44:51 | 栏目:C代码 | 点击:次
我就废话不多说了,直接上代码吧!
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<windows.h> int SUM(char arr[][3]) { int i = 0; int j = 0; int sum = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (i == j) { sum += arr[i][j]; } if (i + j == 2) { sum += arr[i][j]; } } } sum -= arr[1][1]; return sum; } int main() { char arr[3][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; printf("the answer is %d\n",SUM(arr)); system("pause"); return 0; }