Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
co_assign1_ques_4
#include <stdio.h> #include<stdlib.h> #include<time.h> void multiply(int N,int mat1[][N], int mat2[][N], int res[][N]) { int i, j, k; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { res[i][j] = 0; for (k = 0; k < N; k++) res[i][j] += mat1[i][k]*mat2[k][j]; } } } int main() { FILE* fp; fp=fopen("Book3.csv","w"); for(int size=1;size<=700;size+=5){ int N=size; double time; clock_t start; int mat1[N][N]; int mat2[N][N]; int p,q; for(p=0;p<N;p++) { for(q=0;q<N;q++) { mat1[p][q]=1; mat2[p][q]=1; } } int res[N][N]; // To store result int i, j; start=clock(); for(i=0;i<5;i++){ multiply(size,mat1, mat2, res); } time= (double)(clock()-start)/(CLOCKS_PER_SEC*5);///CLOCKS_PER_SEC; printf("\n%d\n Time:%.12f\n\n",size,time); fprintf(fp,"%d,%d,%d,%.12f\n",N,N*N,3*N*N,time); } fclose(fp); return 0; }
run
|
edit
|
history
|
help
0
150109_RecursividadFactorial
pattern
Assignment 8
FloatFahrenheitToCelcius
finding 3 ones in a row
Practice Problem 7
purple ghost red orange blue skulls
prime numbers min>max
Practice
Access the structure variable