1、例如
输出:2 3 4
5 6 7
输入:9
18
2、残缺代码如下
2.1 C++ 版本
#include <iostream>
#include <cstring>
using namespace std;
int a[2][3];
int res[2];
void Sum(int (*p)[3], int total[], int n)
{for(int i = 0; i < n; i++)
{for(int j = 0; j < 3; ++j)
total[i] += p[i][j];
}
}
int main()
{for(int i = 0; i < 2; ++i)
for(int j = 0; j < 3; ++j)
cin >> a[i][j];
Sum(a, res, 2);
for(int i = 0; i < 2; ++i)
cout << res[i] << endl;
return 0;
}
2.2 C 语言版本
#include <stdio.h>
int a[2][3];
int res[2];
void Sum(int(*p)[3], int total[], int n)
{for (int i = 0; i < n; i++)
{for (int j = 0; j < 3; j++)
total[i] += p[i][j];
}
}
int main()
{for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
scanf_s("%d", &a[i][j]);
Sum(a, res, 2);
for (int i = 0; i < 2; i++)
printf("%d\n", res[i]);
return 0;
}
3、截图