#include <stdio.h>
int main()
{
	void productMatrix(int a[][10], int b[][10], int p[][10], int n);
	int i, a[10][10], b[10][10], s[10][10] = {0}, n, j;
	printf("输入你想多少N(1~10)阶的矩阵:");
	scanf("%d", n);
	printf("按行输入矩阵1元素(0~%d行):\n", n - 1);
	for (i = 0; i < n; i++) 
		
		for (j = 0; j < n; j++)
			scanf("%d", &a[i][j]);
	
	printf("按行输入矩阵2元素(0~%d行):\n", n - 1);
	for (i = 0; i < n; i++) 
		for (j = 0; j < n; j++)
		scanf("%d", &b[i][j]);
	
	productMatrix(a, b, s, n);
	printf("矩阵相乘结果:\n");
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
			printf("%d行:%3d", i, s[i][j]);
		printf("\n");
	}
	return 0;
}
void productMatrix(int a[][10], int b[][10], int p[][10],int n) {
	int i, k, j;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			p[i][j] = 0;
			for (k = 0; k < n; k++)p[i][j] += a[i][k] * b[k][i];
		}
	

}