answersLogoWhite

0

#include<stdio.h>

int main()

{

int n,i,j,k,a[10][10];

printf("\nEnter the number of nodes: ");

scanf("%d",&n);

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

{

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

{

printf("\nEnter the distance between the host %d%d:", i+1,j+1);

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

}

}

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

{

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

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

printf("\n");

}

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

{

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

{

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

{

if(a[i][j]>a[i][k]+a[k][j])

a[i][j]=a[i][k]+a[k][j];

}

}

}

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

{

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

{

b[i][j]=a[i][j];

if(i==j)

b[i][j]=0;

}

}

printf("\nThe output matrix is:\n");

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

{

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

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

printf("\n");

}

return 0;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

If vector c equals vector a plus vector b under what circumstances does c equal a minus b?

When b is zero.


What statement describes a route that has been learned dynamically?

Full question is: What describes a route learned dynamically It is A identified by the prefix C in the routing table B automatically updated and maintained by routing protocols C unaffected by changes in the topology of the network D an administrative distance of 1 Answer: It is automatically updated and maintained by routing protocols.


What is flat routing protocol of DSDV?

Destination-Sequenced Distance-Vector Routing (DSDV) is a table-driven routing scheme for ad hoc mobile networks based on the Bellman-Ford algorithm. It was developed by C. Perkins and P.Bhagwat in 1994. The main contribution of the algorithm was to solve the routing loop problem. Each entry in the routing table contains a sequence number, the sequence numbers are generally even if a link is present; else, an odd number is used. The number is generated by the destination, and the emitter needs to send out the next update with this number. Routing information is distributed between nodes by sending full dumps infrequently and smaller incremental updates more frequently.


If vector A has a magnitude of 14 meters and vector B has a magnitude of 6 meters Vector C equals A-B The magnitude of C cannot be?

The magnitude of C cannot be &gt;20.


If vector A is perpendicular to vector B and C then Vector A is parallel to?

Vector A is parallel to the cross product of vectors B and C, and it is parallel to the axis that neither B or C lie along if the two other axes are defined as the axes that B and C lie along.


What is the implementation of the distance function in C for calculating the distance between two points in a program?

To implement the distance function in C for calculating the distance between two points in a program, you can use the formula for Euclidean distance: double distance sqrt(pow((x2 - x1), 2) pow((y2 - y1), 2)); This formula calculates the distance between two points (x1, y1) and (x2, y2) in a Cartesian coordinate system.


How do you write a c plus plus program to sort a vector of strings using MSD radix sort?

The standard library sort algorithm automatically uses MSD radix to sort strings: std::vector&lt;std::string&gt; vs = {"a", "b", "c" "d", "ab"}; std::sort(vs.begin(), vs.end()); After sorting, the order will be: {"a", "ab", "b", "c", "d"}


What has the author C D Collinson written?

C. D. Collinson has written: 'Introductory vector analysis' -- subject(s): Vector analysis


What is the time complexity of the pushback operation in a C vector?

The time complexity of the pushback operation in a C vector is O(1), which means it has constant time complexity. This means that the time it takes to add an element to the end of the vector does not depend on the size of the vector.


What is the time complexity of the vector pushback operation in C?

The time complexity of the vector pushback operation in C is O(1) on average, but can be O(n) in the worst case scenario when the vector needs to be resized.


The figure shows two vector B and C along with magnitude and direction . D is given by D =B -C. What is the magnitude of vector of D What angle does vector D make with the +x-axis?

Nothing


What do the 'c' and 'v' in argc and argv stand for?

c for count v for vector