Skip to content

Instantly share code, notes, and snippets.

@g14a
Created October 6, 2018 16:17

Revisions

  1. g14a created this gist Oct 6, 2018.
    49 changes: 49 additions & 0 deletions serial.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<omp.h>

    int main() {

    int graph[200][200];

    time_t t;
    srand((unsigned) time(&t));

    for (int m=0;m<200;m++) {
    for(int o=0;o<200;o++) {
    graph[m][o] = rand() % 2;

    if(m==o) {
    graph[m][o] = graph[o][m];
    }
    }
    }

    long double start = omp_get_wtime();

    int i=0,j=0,k=0,l=0;
    int count=0;


    for(i=0;i<200;i++) {
    for (j=i;j<200;j++) {
    for(k=j;k<200;k++){
    for(l=k;l<200;l++) {
    if(graph[i][j] && i!=j) {
    if(graph[i][k] && graph[j][k] && k!=j && k!=i) {
    count++;
    printf("[%d %d %d %d]\n", i, j, k, l);
    }
    }
    }
    }
    }
    }

    printf("\n%Lf\n", omp_get_wtime()-start);

    printf("Num : %d\n", count);

    return 0;
    }