windows api로 다익스트라 알고리즘 구현하기 질문.

jins8160의 이미지

제가 c랑 알고리즘을 공부해서 c로 다익스트라 알고리즘을 만들어봤는데, 이제 하기 시작한 windows api로도 만들어보고 싶은데 어떻게 해야될지 하나도 모르겠어요 .좀 알려주세요....

#include <stdio.h>
#include <string.h>
 
#define N 10
#define M 9999
 
int a[N+1][N+1]={
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,1,M,M,M,M,M,M,M,M},//1
{0,1,0,1,M,M,M,M,M,M,M},//2
{0,M,1,0,1,M,M,M,M,M,M},//3
{0,M,M,1,0,1,M,M,M,M,M},//4
{0,M,M,M,1,0,1,M,M,M,M},//5
{0,M,M,M,M,1,0,1,M,M,M},//6
{0,M,M,M,M,M,1,0,1,M,M},//7
{0,M,M,M,M,M,M,1,0,1,M},//8
{0,M,M,M,M,M,M,M,1,0,1},//9
{0,M,M,M,M,M,M,M,M,1,0}};//10
// 1.2.3.4.5.6.7.8.9.10
 
typedef struct {
 char *state;
 int state_num;
}SubType;
 
SubType subway[N+1]={"null",0,"신평",1,"하단",2,"당리",3,"사하",4,"괴정",5,"대티",6,
	"서대신동",7,"동대신동",8,"토성동",9,"자갈치",10};
 
int main(void)
{
	int j,k,p,start,end,min,i=0,count=0,
	leng[N+1], // 정점까지의 거리
	v[N+1], //확정 플래그 
	index[N+1];
 
	start=subway[1].state_num; // 시작점 입력
 
	for(k=1;k<=N;k++) // 초기화
	{
		leng[k]=M;  
		v[k]=0;
	}
 
	leng[start]=0;  /* 시작점은 표시하지 않는다 */
	index[start]=0; 
 
	for(j=1;j<=N;j++)
	{
		min=M;
 
		for(k=1;k<=N;k++) // 최단거리 정점을 찾는다
		{
			if(v[k]==0 && leng[k]<min)
			{
				p=k;
				min=leng[k];
			}
		}
 
		v[p]=1; // 최소인 정점을 확정
 
		if(min==M)
		{
			printf("그래프가 연결되어 있지 않다\n");
			return 1;
		}
 
		// p를 경유해서 k에 이르는 거리가 지금까지의 최단 경로보다 작으면 갱신 
		for(k=1;k<=N;k++)
		{
			if((leng[p]+a[p][k])<leng[k]) 
			{
				leng[k]=leng[p]+a[p][k];
				index[k]=p;
			}
		}
	}
 
	for(j=2;j<=N;j++) // 도착 경로 출력 함수
	{
		p=j;
		while(index[p]!=0)
		{
			printf("%s -> ",subway[index[p]].state);
			p=index[p];
		}
		printf("\n");	
	}
	return 0;
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.