initial commit

This commit is contained in:
AustrianToast 2024-09-26 14:32:20 +02:00
parent 72edcbd75d
commit 32541218bc
Signed by: AustrianToast
GPG Key ID: 1B4D0AAF6E558816
5 changed files with 58 additions and 0 deletions

17
graph.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdint.h>
#include <time.h>
#include <stdlib.h>
void random_adjacency(const uint64_t row_length, const uint64_t column_length, uint64_t matrix[row_length][column_length]) {
srand(time(NULL));
for (uint8_t row_index=0; row_index < row_length; row_index++) {
for (uint8_t column_index=0; column_index < column_length; column_index++) {
if(column_index == row_index) {
matrix[row_index][column_index] = 1;
continue;
}
matrix[row_index][column_index] = rand()%2;
}
}
}

8
graph.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef GRAPH_H
#define GRAPH_H
#include <stdint.h>
void random_adjacency(const uint64_t row_length, const uint64_t column_length, uint64_t matrix[row_length][column_length]);
#endif

14
main.c Normal file
View File

@ -0,0 +1,14 @@
#include "graph.h"
#include "matrix.h"
#include <stdint.h>
int main(void) {
const uint8_t row_length = 5;
const uint8_t column_length = 5;
uint64_t matrix[row_length][column_length];
random_adjacency(row_length, column_length, matrix);
print_matrix(row_length, column_length, matrix);
}

11
matrix.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdint.h>
#include <stdio.h>
void print_matrix(const uint8_t row_length, const uint8_t column_length, const uint64_t matrix[row_length][column_length]) {
for (uint8_t column_index=0; column_index < column_length; column_index++) {
for (uint8_t row_index=0; row_index < row_length; row_index++) {
printf("%lu ", matrix[row_index][column_index]);
}
printf("\n");
}
}

8
matrix.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef MATRIX_H
#define MATRIX_H
#include <stdint.h>
void print_matrix(const uint64_t row_length, const uint64_t column_length, const uint64_t matrix[row_length][column_length]);
#endif