标签:++ string rand 矩阵相乘 div code print pac include
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
void main()
{
int a[4][4];
int b[4][4];
int c[4][4];
int i,j,k,s,t,m,n;
srand(time(0));
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
a[i][j]=rand()%20+1;
printf("a is \n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%5d",a[i][j]);
printf("\n");
printf("\n");
}
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
b[i][j]=rand()%20+1;
printf("b is \n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%5d",b[i][j]);
printf("\n");
printf("\n");
}
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
c[i][j]=a[i][j]+b[i][j];
printf("c is \n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%5d",c[i][j]);
printf("\n");
printf("\n");
}
int z;
z=0;
printf("a is \n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
printf("%5d",a[i][j]);
printf("\n");
printf("\n");
}
int my=0;
int sb=0;
k=0;
int jsq=0;
printf("my is : \n");
for(k=0;k<=3;k++)
{
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
sb=a[k][j]*b[j][i];
my=my+sb;
}
c[k][i]=my;
printf("%5d",c[k][i]);
jsq++;
if(jsq%4==0)
printf("\n");
my=0;
}
}
}
标签:++ string rand 矩阵相乘 div code print pac include
原文地址:https://www.cnblogs.com/jx3ajmd/p/9610398.html