The Random Thread

Oops! I did it again.

1788683323314.png
 
Like I said, it can be addictive. I suppose you could try something like, I'll only post on the forums after I've written one page, or something similar.
 
I told ChatGPT to "Write Dijkstra’s shortest-path algorithm in C but upside-down, that is, first the last line, second the penultimate, etc." Why? To see how it looks. I looks funny.

C:
}
    return 0;

    dijkstra(graph, source);

    int source = 0;

    };
        {14, 0, 2, 0, 9, 0}
        {0, 0, 0, 6, 0, 9},
        {0, 15, 11, 0, 6, 0},
        {9, 10, 0, 11, 0, 2},
        {7, 0, 10, 15, 0, 0},
        {0, 7, 9, 0, 0, 14},
    int graph[V][V] = {
int main(void) {

}
    }
        }
            printf("\n");
            print_path(parent, v);
            printf("distance = %d, path = ", dist[v]);
        } else {
            printf("unreachable\n");
        if (dist[v] == INF) {

        printf("Vertex %d: ", v);
    for (int v = 0; v < V; v++) {

    printf("Source: %d\n\n", source);

    }
        }
            }
                parent[v] = u;
                dist[v] = dist[u] + graph[u][v];

                dist[u] + graph[u][v] < dist[v]) {
                dist[u] != INF &&
                graph[u][v] > 0 &&
            if (!visited[v] &&
        for (int v = 0; v < V; v++) {

        visited[u] = 1;

        }
            break;
        if (u == -1) {

        int u = min_distance(dist, visited);
    for (int count = 0; count < V - 1; count++) {

    dist[source] = 0;

    }
        parent[i] = -1;
        visited[i] = 0;
        dist[i] = INF;
    for (int i = 0; i < V; i++) {

    int parent[V];
    int visited[V];
    int dist[V];
void dijkstra(int graph[V][V], int source) {

}
    printf("%d", vertex);

    }
        printf(" -> ");
    if (parent[vertex] != -1) {

    print_path(parent, parent[vertex]);

    }
        return;
    if (vertex == -1) {
void print_path(int parent[], int vertex) {

}
    return min_index;

    }
        }
            min_index = v;
            min = dist[v];
        if (!visited[v] && dist[v] < min) {
    for (int v = 0; v < V; v++) {

    int min_index = -1;
    int min = INF;
int min_distance(int dist[], int visited[]) {

#define INF INT_MAX
#define V 6

#include <limits.h>
#include <stdio.h>
 
Back
Top