переведите плз На паскаль #include #include #include #define MAX 30000 struct List{ int v; int w; struct List *next; }; struct Graph{ int h; int p; struct List *first; struct List *last; }*G; int N; int V; void Ford(); void BelmanKalab(); void PathFord(int ); void Menu(); void ListAdj(); void FreeList(); void main() { Menu(); } void BelmanKalab() { int i,j,k; struct List *c; int **M=(int **)malloc(N*sizeof(int *)); int *VK=(int *)malloc(N*sizeof(int )); int *VK_1=(int *)malloc(N*sizeof(int )); int *t,f=1; int *P=(int *)malloc(N*sizeof(int )); for(i=0;i M=(int *)malloc(N*sizeof(int)); for(i=0;i for(j=0;j M[j]=(i==j)?0:MAX; for(i=0;i c=G.first; while(c!=G.last){ M[c->v]=c->w; c=c->next; } } printf("Enter final vertex: "); scanf("%d",&V); V--; for(i=0;i VK_1=M[V]; P=-1; } while(f){ for(i=0;i VK=MAX; for(i=0;i for(j=0;j if(i!=j && VK>VK_1[j]+M[j]){ VK=VK_1[j]+M[j]; P=j; } VK[V]=0; for(i=0;i ; f=(i==N)?0:1; t=VK_1; VK_1=VK; VK=t; } for(i=0;i printf("\nPath from %d to %d is ",i+1,V+1); if(VK_1==MAX) printf("not exist."); else { for(k=i,j=0;j printf("->%d",k+1); k=P[k]; } printf("->%d",V+1); printf(". It has length %d.",VK_1); } } for(i=0;i free(M); free(P); free(M); free(VK); free(VK_1); } void Ford() { int i,f=1; struct List *c; if(G==NULL) return; for(i=0;i G.p=-1; G.h=MAX; } printf("Enter start vertex: "); scanf("%d",&V); G[--V].h=0; while(f){ f=0; for(i=0;i c=G.first; while(c!=G.last){ if(G[c->v].h>G.h+c->w){ G[c->v].h=G.h+c->w; G[c->v].p=i; f=1; } c=c->next; } } } for(i=0;i printf("\nPath from %d to %d is ",V+1,i+1); if(G.h==MAX) printf("not exist."); else{ PathFord(i); printf(". It has length %d.",G.h); } } } void PathFord(int v) { if(v!=V) PathFord(G[v].p); printf("->%d",v+1); } void Menu() { int i; char ch; clrscr(); printf("1.To enter the graph\n"); printf("2.Minimum path by Ford's algorithm\n"); printf("3.Minimum path by Belman-Kalab's algorithm\n"); printf("4.Exit\n"); do ch=getch(); while(ch<'0' || ch>'5'); clrscr(); switch (ch) { case '1': ListAdj();break; case '2': Ford();getch();break; case '3': BelmanKalab();getch();break; case '4': FreeList();return; } Menu(); } void ListAdj() { int i,v,w; struct List *c; if(G) FreeList(); printf("Enter number of vertexes of graph: "); scanf("%d",&N); G=(struct Graph *)malloc(N*sizeof(struct Graph)); printf("\n"); for(i=0;i printf("%d->",i+1); G.first=(struct List*)malloc(sizeof(struct List)); G.last=G.first; G.last->next=NULL; G.last->v=-1; scanf("%d",&v); while(v){ scanf("%d",&w); G.last->v=v-1; G.last->w=w; G.last->next=(struct List*)malloc(sizeof(struct List)); G.last=G.last->next; G.last->next=NULL; G.last->v=-1; scanf("%d",&v); } } } void FreeList() { struct List *c,*t; while(N--){ c=G[N].first; while(c!=G[N].last){ t=c->next; free©; c=t; } } free(G); }