Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CO_assign_q4
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { FILE * fp; fp = fopen ("output.csv","w"); srand ((unsigned int ) time (NULL)); double timeTaken; clock_t start; for (int size = 5; size <= 250; size +=5){// decrease the time if you get Kill signal (SIGKILL) int n = size; int a1[n][n]; int a2[n][n]; int amul[n][n]; for(int ro1 =0; ro1<n; ro1++){ for(int co1 = 0; co1<n; co1++ ){ a1[ro1][co1] = rand()%10 ; int p = rand()%2; if (p==1) a1[ro1][co1] *= -1; } } for(int ro2 =0; ro2<n; ro2++){ for(int co2 = 0; co2<n; co2++ ){ a2[ro2][co2] = rand()%10; int q = rand()%2; if (q==1) a2[ro2][co2]*=-1; } } start = clock(); for (int i = 1; i<= 5; i++){ for(int ia = 0; ia <n; ia ++ ){ for(int ib = 0; ib <n; ib++){ amul[ia][ib] = 0; for(int ic = 0; ic<n; ic++){ amul[ia][ib] +=a1[ia][ic] * a2[ic][ib]; } } } } timeTaken = (double)(clock() - start)/(CLOCKS_PER_SEC * 5); printf("Time for %d: %.12f \n", n, timeTaken); fprintf(fp,"%d,%d,%d,%.12f\n",n,n*n,3*n*n,timeTaken); } return 0; }
run
|
edit
|
history
|
help
0
Why &(a+1) is not allowed
Program to input form command line and print it
printing float 2 pointers
A_141212_IntercambiarValores
prime or not
CPTTRN_2
mapOfIndia
What happens if you do a system() in rextester...
Matrix rotation 90-degree
Project 3 Part 1 v1.2