.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

find the path of Matrix to given source and destination

Posted By:laptop charles       Posted Date: December 30, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

It has using matrix, first give the order of matrix and will give source and destination point it will give the value for the current point.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace shortestpath
    class Program
        static void Main(string[] args)
            int[,] a=new int[100,100];
            Console.WriteLine("Enter the order of matrix");
            int n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= n; j++)
                    Console.WriteLine("Enter The "+i+","+j+"Matrix");
                    a[i,j]= int.Parse(Console.ReadLine());

            Console.WriteLine("Enter the source");
            int s = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter the destination");
            int d = int.Parse(Console.ReadLine());

            Console.WriteLine("The path from "+s+" to "+d+" is "+a[s,d]);



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend