검색어 입력폼

# [자료구조론] - C언어 Graph, Sort

저작시기 2013.06 |등록일 2014.05.06 한컴오피스 (hwp) | 12페이지 | 가격 800원

자료구조론

## 목차

1. Graph
1) Program source code
2) Program build output
3) Program execution(screen shot)
4) Program usage
5) Comment

2. Sort
1) Program source code
2) Program build output
3) Program execution(screen shot)
4) Program usage
5) Comment

## 본문내용

1. Graph

(1) Program Source Code

#include <stdio.h>
#include <stdlib.h>

#define INT_MAX100000
#define MAX_VERTICES7// Homework ...
#define TRUE1
#define FALSE0

int choose(int distance[], int n, short int found[])
{
/* find the smallest distance not yet checked */
int i, min, minpos;
min = INT_MAX
minpos = -1;

for (i = 0; i < n i++)
{
if (distance[i] < min &&!found[i])
{
min = distance[i];
minpos = i;
}
}

return minpos;
}

/* distance[i] represents the shortest path from vertex v to i,
if the shortest path from i has not been found, found[i] is 0
and if it has, found[i] = 1, cost is the adjacency matrix */
void shortestPath (int v, int cost[][MAX_VERTICES],
int distance[], int n, short int found[])
{
int i, u, w;

for (i = 0; i < n i++)
{
found[i] = FALSE
distance[i] = cost[v][i];
}

found[v] = TRUE
distance[v] = 0;

없음