Skip to content
Snippets Groups Projects
Commit 435bbee0 authored by Arnold Sianturi's avatar Arnold Sianturi
Browse files

Commit changes and fixing bugs

parent f149662c
Branches
No related merge requests found
# Test
\ No newline at end of file
test2
\ No newline at end of file
#define inf 999999
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include <time.h>
//void keluaran(int* mat[], int b, int k);
int main()
{
int N;
scanf("%d", &N);
int i, j, mat[100][100];
srand(13516001);
#pragma omp parallel for num_threads(10)
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
//mat[i * N + j] = rand() % 1000;
if (i == j)
{
mat[i][j] = 0;
}
else if (mat[i][j] > 800)
{
mat[i][j] = inf;
mat[j][i] = inf;
}
else
{
int temp = rand() % 1000;
mat[i][j] = temp;
mat[j][i] = temp;
}
}
}
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
printf("Elemen baris %d, kolom %d : %d\n", i, j, mat[i][j]);
}
}
//keluaran(mat, N, N);
FILE* fp;
fp = fopen("file.txt", "w");
//int i, j;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
if (j == N - 1)
{
fprintf(fp, "%d\n", mat[i][j]);
}
else
{
fprintf(fp, "%d ", mat[i][j]);
}
}
}
return 0;
}
img/100 nodes.png

52.7 KiB

img/1000 nodes.png

62.3 KiB

img/500 nodes.png

52 KiB

This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File moved
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment