现在的位置: 首页 > 综合 > 正文

第5周作业

2014年11月11日 ⁄ 综合 ⁄ 共 660字 ⁄ 字号 评论关闭
// 66.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int i,j,max,m,n;
	int a[4][5],b[5][3],c[4][3]={0};
	cout<<"请为矩阵a[4][5]输入任意20个整数:";
	for(i=0;i<4;i++)
	{
		for(j=0;j<5;j++)
		cin>>a[i][j];
	}
		for(i=0;i<4;i++)
		{
		for(j=0;j<5;j++)
				cout<<setw(6)<<a[i][j];
		cout<<endl;
		}
		
	cout<<"请为矩阵b[5][3]输入任意15个整数:";
	for(m=0;m<5;m++)
	{
		for(n=0;n<3;n++)
		cin>>b[m][n];
	}
		for(m=0;m<5;m++)
		{
		for(n=0;n<3;n++)
				cout<<setw(6)<<b[m][n];
		cout<<endl;
		}
		for(i=0;i<4;i++)
		for(j=0;j<5;j++)
		for(m=0;m<5;m++)
		for(n=0;n<3;n++)
		c[i][n]+=a[i][j]*b[m][n];
		cout<<"它们的积为:"<<endl;
		for(i=0;i<4;i++)
		{
		for(n=0;n<3;n++)
		cout<<setw(8)<<c[i][n];
		cout<<endl;
		}
		return 0;
}

【上篇】
【下篇】

抱歉!评论已关闭.