answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#include<string.h>

void min(int[],int,int[][],int);

void main()

{

int s[20][20],i,j,n,ne[20][20],k=0,d[20],z[20][2],e[20];

char nam[20],r;

clrscr();

printf("enter no.of routers in the subnet:");

scanf("%d",&n);

printf("Enter the adjacency matrix\n");

for(i=0;i<n;i++)

for(j=0;j<n;j++)

scanf("%d",&s[i][j]);

printf("Which routers routing table you want to construct:");

scanf(%c",&r);

printf("the neighbours of c are:",r);

for(i=0;i<n;i++)

if(s[r-65][i]==1)

{

printf("%c",i+65);

nam[k++]=i+65;

}

printf("\n");

for(i=0;i<k;i++)

{

printf("Enter %c%c delay:",r,nam[i]);

scanf("%d",&d[i]);

}

for(i=0;i<k;i++)

{

printf("\n Enter %c's routing table \n",nam[i]);

for(j=0;j<n;j++)

scanf("%d",&ne[i][j];

}

for(i=0;i<n;i++)

{

for(j=0;j<k;j++)

e[j]=ne[i][j]+d[j];

min(e,k,z,i);

}

clrscr();

printf("To");

for(i=0;i<k;i++)

printf("%c\t",nam[i]);

printf("NEW TABLE FOR %c ",r);

printf("\n");

for(i=0;i<k;i++)

printf("......");

printf("..............");

for(i=0;i<n;i++)

{

printf("\n");

printf("%c|",i+65);

for(j=0;j<k;j++)

printf("%d\t",ne[j][i]);

if(r==(i+65))

printf("0\t-);

else

{

printf("%d\t",z[i][0]);

printf("%c\t",nam[z[i][1]]);

}

}

}

void min(int e[20],int k,int z[20][2],int i)

{

int b;

z[i][0]=e[0];

z[i][1]=0;

for(b=1;b<k;b++)

if(e[b]<z[i][0])

{

z[i][1]=0;

for(b=1;b<k;b++)

if(e[b]<z[i][0])

{

z[i][0]=e[b];

z[i][1]=b;

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

20 miles per hour is an example of?

A speed measurement indicating the distance traveled in an hour.


Can you provide an example of a second chance page replacement algorithm in operating systems?

An example of a second chance page replacement algorithm in operating systems is the Clock algorithm. This algorithm works by using a circular list of pages and a &quot;use&quot; bit for each page. When a page needs to be replaced, the algorithm checks the &quot;use&quot; bit of each page in the list. If the bit is set, indicating the page has been recently used, the algorithm clears the bit and moves to the next page. This process continues until a page with a cleared &quot;use&quot; bit is found, which is then replaced.


What is the example of finiteness in algorithm?

An example of finiteness in algorithm is when a loop within the algorithm has a predetermined number of iterations, meaning it will only run a specific number of times before completing. This ensures that the algorithm will eventually terminate and not run indefinitely.


Example of md5 algorithm?

fdf


What is an example of communication style?

Distance between speakers


How does the Greedy Algorithm work?

There is not "a" greedy algorithm; "greedy algorithm" is a term to describe several algorithms that have some things in common. The general idea is that at each step, you look for what seems to be, "locally", the best solution. For example, in a shortest-distance problem, look for a step that takes you closer to the destination. This may, or may not, lead to the best solution overall.


What is distance between 00 and 28?

It is 28 (for example km)


What is a example of communication style?

distance between speakers (apex )


What is an example of wavelength?

An example of wavelength is the distance between two consecutive peaks of a wave, such as the distance between two successive crests of an ocean wave or two peaks of a sound wave. In electromagnetic radiation, the wavelength is the distance between two successive peaks of the wave, like the distance between two peaks of a light wave.


What is an algorithn?

If you mean "Algorithm" an algorithm is simply a set of rules, or steps to complete, which are needed to solve a particular problem. An example would be a recipe in a cookbook. A recipe is an algorithm.


How does distance has no direction?

Distance is a scalar quantity that measures the amount of space between two points. It only represents the magnitude of separation without indicating the direction of travel. In contrast, displacement is a vector quantity that includes both distance and direction.


What is the distance between New York and Missouri?

The distance between New York and Missouri varies depending on the cities you are traveling between. For example, the distance between New York City and St. Louis, Missouri is approximately 875 miles.