3阶矩阵的乘法

Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
c-source:
 #include<stdio.h>
#define M 3
#define N 3
void main()
{
int t[M][N],b[M][N];
int n; printf("The number of n:\n");
scanf("%d",&n); int **answer=new int *[n];
for(int i=;i<n;i++)
answer[i] = new int[]; for(int q1=;q1<n;q1++)
for(int q2=;q2<;q2++)
answer[q1][q2]=; for(int k=;k<n;k++)
{
for(int i1=;i1<M;i1++)
for(int j5=;j5<N;j5++)
scanf("%d",&t[i1][j5]); for(int i2=;i2<M;i2++)
for(int j2=;j2<N;j2++)
scanf("%d",&b[i2][j2]); printf("\n"); for(int i3=;i3<M;i3++)
for(int j3=;j3<N;j3++)
{
for(int q=;q<M;q++)
{
answer[k][i3*M+j3]+=t[i3][q]*b[q][j3];
}
}
} for(int p=;p<n;p++)
{
for(int j4=;j4<;j4++)
{
if(j4%==)
printf("\n");
printf("%d ",answer[p][j4]);
}
printf("\n\n");
} for(i=;i<n;++i)
delete[] answer[i];
delete[] answer;
}

知识点:

 
⒈new二维数组M*N;
   int **a=new int *[M];
  for(int i=;i<M;i++)
  a[i]=new int[N];
⒉动态分配必须由程序自行释放空间:
for(int j=;j<M;j++)
  delete[] a[j];
  delete [] a;
M*P与P*N维矩阵相乘的问题:
 for(int i=;i<M;i++)
for(int j=;j<N;j++)
{
for(int k=;k<p;k++)
answer[i][j]+=a[i][k]*a[k][j];
}

电子科大POJ "3*3矩阵的乘法"的更多相关文章

  1. 电子科大POJ "任意阶矩阵相乘"

    任意阶矩阵的乘法 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sourc ...

  2. 电子科大POJ "统计单词"

    统计单词 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sources: ...

  3. 电子科大POJ "敲错键盘"

    C-sources: #include<stdio.h> #define N 20 int main() { int i,j; ]={'Q','W','E','R','T','Y','U' ...

  4. 电子科大POJ "孤单整数"

    孤单整数 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sources: ...

  5. 电子科大POJ "整数的千位分隔"

    整数的千位分隔 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-source ...

  6. 电子科大POJ "a^b"

    a ^ b Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) C-sources: ...

  7. 实现两个N*N矩阵的乘法,矩阵由一维数组表示

    实现两个N*N矩阵的乘法,矩阵由一维数组表示. 先介绍一下矩阵的加法: void Add(int rows, int cols) { ;i<rows;i++) { ;j<cols;j++) ...

  8. POJ1260 Pearls(dp,矩阵链乘法)

    题目链接. 题目大意: 给定一个n,和两个序列a[i], p[i]. a[i] 表示需要购买 i品质 的数量,p[i] i 等级的价格. 1.每个品质都会有不同的价格,价格依据品质上升而上升 2.买一 ...

  9. python使用post登陆电子科大信息门户并保存登陆后页面

    python使用post登陆电子科大信息门户并保存登陆后页面 作者:vpoet mail:vpoet_sir@163.com #coding=utf-8 import HTMLParser impor ...

随机推荐

  1. Merge Sorted Array 解答

    Question Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array ...

  2. 【HDU2120】Ice_cream's world I(并查集基础题)

    查环操作,裸题.一次AC. #include <iostream> #include <cstring> #include <cstdlib> #include & ...

  3. Fabricate equation(dfs + 模拟)

    Fabricate equation Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Other ...

  4. MooseFS源代码分析(三)

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  5. linux TIME_WAIT过多的解决方法

      查看TCP状态:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'查看SOCKET状态:cat /proc/n ...

  6. Afianl加载网络图片(延续)

    上一页"已经谈到了如何使用Afianl网络负载的图片和下载文件,本文将继续介绍使用Afinal使用网络负载图片,主绑定listview采用: 看效果图: listview在滑动过程中没用明显 ...

  7. TabBarItem图片大小改变

    在TabBarItem设计的时候不需要title只要image的时候,如何将image居中显示. tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, ...

  8. 微信jssdk批量展示卡包中的卡券

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  9. EffectiveC#02--仅在对基类进行强制更新时才使用new修饰符

    1.建议避免使用new修饰符来重新定义非虚函数. 非虚方法是静态绑定的,不管哪里的代码也不管在哪里引用, 它总是严格的调用类中所定义的函数.并不会在运行时在 派生类中查找不同的版本. 2.何时使用ne ...

  10. jQuery中click()与trigger方法的区别

    click()可以执行单击事件,但是不可传参. $("button").click(function(){ alert("hello."); }); trigg ...