C语言编程题,求出如下所示矩阵中各行元素之和,并以矩阵形式输出原矩阵及相应行元素之和

[复制链接]
查看11 | 回复3 | 2008-11-25 13:41:16 | 显示全部楼层 |阅读模式
3 5 6 8
2 1 4 9
8 7 1 6

回复

使用道具 举报

千问 | 2008-11-25 13:41:16 | 显示全部楼层
#includevoid main(){int a[3][4]={3,5,6,8,2,1,4,9,8,7,1,6};int i,j,sum;for(i=0;i<3;i++){ for(j=0;j<4;j++) {printf("%4d",a[j]); } printf("\n");}printf("sum of the line:\n");for(i=0;i<3;i++){ for(j=0,sum=0;j<4;j++) {sum=sum+a[j]; } printf("The Line%d's sum:%d\n",i+1,sum);...
回复

使用道具 举报

千问 | 2008-11-25 13:41:16 | 显示全部楼层
#include "stdio.h"void main(){int i,j,sum;int h[4]={0};int a[4][5]={{0},{0,3,5,6,8},{0,2,1,4,9},{0,8,7,1,6}};for(i=1;i<4;i++){sum=0; for(j=1;j<5;j++) ...
回复

使用道具 举报

千问 | 2008-11-25 13:41:16 | 显示全部楼层
int a[3][5]={3,5,6,8,0,2,1,4,9,0,8,7,1,6,0}for(int i=0;i<2;i++)for(int j=0;j<3;j++) a[5]=a[5]+a[j];for(i=0;i<2;i++){ for(j=0;j<4;j++)
printf("%d ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行