Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int n, m;

            string[] tokens = Console.ReadLine().Split(' ');
            n = int.Parse(tokens[0]);
            m = int.Parse(tokens[1]);

            while (n != 0 && m != 0)
            {
                map map = new map(n);
                for (int i = 0; i < m; i++)
                {
                    tokens = Console.ReadLine().Split(' ');
                    int    u = int.Parse(tokens[0]);
                    int    v = int.Parse(tokens[1]);
                    double w = double.Parse(tokens[2]);
                    map.addLink(u, v, w);
                }
                Console.WriteLine(map.escape().ToString("N4"));

                tokens = Console.ReadLine().Split(' ');
                n      = int.Parse(tokens[0]);
                m      = int.Parse(tokens[1]);
            }

            Console.Read();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Dictionary <string, node> students = new Dictionary <string, node>();

            string[] line = Console.ReadLine().Split(' ');

            int s   = int.Parse(line[0]);
            map map = new map(s);

            for (int i = 0; i < s; i++)
            {
                line = Console.ReadLine().Split(' ');
                string studentName = line[0];
                node   student     = new node(studentName, i);
                map.addStudent(student);
                students.Add(studentName, student);
            }

            line = Console.ReadLine().Split(' ');
            int friendships = int.Parse(line[0]);

            for (int i = 0; i < friendships; i++)
            {
                line = Console.ReadLine().Split(' ');
                string friend1 = line[0];
                string friend2 = line[1];

                // add a link from friend1 to friend2
                map.addLink(students[friend1], students[friend2]);
            }

            map.sort();

            line = Console.ReadLine().Split(' ');
            int r = int.Parse(line[0]);

            string[] starters = new string[r];
            for (int i = 0; i < r; i++)
            {
                line = Console.ReadLine().Split(' ');
                string starter = line[0];

                starters[i] = starter;

                foreach (string el in map.betterspread(students[starter]))
                {
                    Console.Write(el + " ");
                }
                Console.WriteLine();
            }
            Console.Read();
        }