From 7ded8989e4df29855e4fc1486e0fb004070d69c2 Mon Sep 17 00:00:00 2001 From: Arnav Goyal Date: Wed, 1 Jun 2022 01:36:08 +0530 Subject: [PATCH] strassens matrix multiplication using C --- ...ssen\342\200\231s Matrix Multiplication.c" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "c/Strassen\342\200\231s Matrix Multiplication.c" diff --git "a/c/Strassen\342\200\231s Matrix Multiplication.c" "b/c/Strassen\342\200\231s Matrix Multiplication.c" new file mode 100644 index 0000000..cb77314 --- /dev/null +++ "b/c/Strassen\342\200\231s Matrix Multiplication.c" @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include + +int main() +{ + int n; + printf("Enter the size of the two arrays: "); + scanf("%d", &n); + + int a[n][n]; + int b[n][n]; + int answer[n][n]; + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + printf("Enter the value of a%d%d: ", i + 1, j + 1); + scanf("%d", &a[i][j]); + } + } + + printf("\n"); + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + printf("Enter the value of b%d%d: ", i + 1, j + 1); + scanf("%d", &b[i][j]); + } + } + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + answer[i][j] = 0; + for (int k = 0; k < n; k++) + { + answer[i][j] += a[i][k] * b[k][j]; + } + } + } + + printf("\n\nThe resultant matrix looks like:\n\n"); + { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (j == n - 1) + { + printf("%d\n", answer[i][j]); + break; + } + printf("%d\t", answer[i][j]); + } + } + } + + return 0; +} \ No newline at end of file