资源描述:
《C语言程序设计教程第七章课后习题参考答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、P1983求主、副对角线元素之和#include#defineM4#defineN4intmain(){inta[M][N]={l,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};inti,j,m=0,n=0;for(i=0;i2、%d”,m);for(i=0;ivoidinput(inta[],intn);voidreverse(inta[],intn);intmain(){inta[5];intsize=sizeof(a)/sizeof(int);input(a,size);reverse(a,size);printfC'n”);r
3、eturn0;}voidinput(inta[],intn){inti;printff'W输入%d个整数:",n);for(i=0;ivn;i++){scanf("%d",&a[i]);}}voidreverse(inta[],intn){inti,t;for(i=0;ivoidreverse(inta[],int
4、n);voidprint(inta[],intn);intmain(){inta[]={l,2,3,4,5,11,16,13};intsize=sizeof(a)/sizeof(int);print(a,size);reverse(a,size);printfJAn11);return0;}voidprint(inta[],intn){inti;printff"原:”);for(i=0;i5、i;printf(”逆序:”);for(i=0;ivoidprint(inta[][3],introws」ntcols);intfun(inta[][3]zintrowsjntclos);voidmain(){血⑶⑶禹;printf("input:");for(i=0;i<3;i++)for(j=0;j<3;j++
6、)scanf(”%cf:&a[i][j]);}print(a,3,3);if(fun(a,3,3)==0)printf("此矩阵是对称矩阵“);elseprintf("此矩阵不是对称矩阵");}voidprint(inta[][3],introwsjntcols){inti,j;for(i=0;i7、0)return1;elsereturn0;}P1985对称矩阵(2)#include#defineM3#defineN3voidprint(inta[][N],intm,intn);intyan(inta[][N],intm,intn);intmain(){inta[][N]={1234567,&9};print(a,M,N);if(yan(a,M,N))printf(”YES”);else
8、printf("NO");return0;}voidprint(inta[][N],intm,intn){intij;for(i=0;i