求一个矩形方阵两对角线的元素和#include#includeint main(){int i,j=0,sum=0,k,n;printf("请输入行列数:");scanf("%d",&n);printf("行列数为:%d",n);int a[n][n];printf("请输入元素的值:");for(i=0;i
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/29 01:11:29
求一个矩形方阵两对角线的元素和#include#includeint main(){int i,j=0,sum=0,k,n;printf("请输入行列数:");scanf("%d",&n);printf("行列数为:%d",n);int a[n][n];printf("请输入元素的值:");for(i=0;i
求一个矩形方阵两对角线的元素和
#include
#include
int main()
{int i,j=0,sum=0,k,n;
printf("请输入行列数:");
scanf("%d",&n);
printf("行列数为:%d",n);
int a[n][n];
printf("请输入元素的值:");
for(i=0;i
求一个矩形方阵两对角线的元素和#include#includeint main(){int i,j=0,sum=0,k,n;printf("请输入行列数:");scanf("%d",&n);printf("行列数为:%d",n);int a[n][n];printf("请输入元素的值:");for(i=0;i
有的地方修改了下,用动态数组就可以解决.
#include
#include
int main()
{int i,j=0,sum=0,k=0,n;
int **a;
printf("请输入行列数:");
scanf("%d",&n);
printf("行列数为:%d",n);
a= (int **) malloc(sizeof(int *)*n);
for(int i=0 ; i !=n ; i++)
a[i]=(int *) malloc(sizeof(int )*n);
printf("请输入元素的值:");
for(i=0;i