题目内容:
程序定义了M×M的二维数组,并在主函数中自动赋值。请编写函数proc(int a[][M],int n),该函数的功能是使数组左下半三角元素中的值加上n。例如,a数组中的值为:
若n的值为2,则返回主程序后a数组中的值为:

注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若十语句。
试题程序:
#inelude<time.il>
#inelude<stdio.h>
#inelude<conio.h>
#include<stdlib h>
#defineM 5
void proc(int a[][M],int n)
{
}
void main()
{
int n=2,i,j;
int arr[5][5]={1,2,3,4,5,6,7,8,9,10,11,l2,l3,
14,15,16,17,18,19,20,21,22,23,24,25);
system("CLS"):
printf("****The array****\n");
printf("n=%4d\n",n);
proc(arr,n):
printf("****THE RESULT****\n");
for(i=0;i<M;i++)
{
for(j=0;j<M;j++)
printf("%4d",arr[i][j]):
printf("\n");
}
}
参考答案:
答案解析: