示例#1
0
            public bool InComponent(string component)
            {
                bool match = ModulesL[this.Component].Designator == component;

                if (match)
                {
                    Debugger.Break();
                }
                return(match);

                var Designators = new List <string>();
                GFG gg          = new GFG();
                int i           = 0;

                foreach (var Module in ModulesL)
                {
                    Designators.Add(Module.Designator);
                    if (component == Module.Designator)
                    {
                        return(true);
                    }
                    i++;
                }
                Designators.Sort(gg);
                return(false);
            }
示例#2
0
    // Driver Code
    public static void Main(String[] args)
    {
        /* Let us create the following weighted graph
         * 10
         * (0)------->(3)
         |	 /|\
         | 5 |	 |
         |	 | 1
         \|/ |
         | (1)------->(2)
         | 3	 */

        /* Let us create the following weighted graph
         *
         *      10
         * (0)------->(3)
         |	 /|\
         | 5 |	 |
         |	 | 1
         \|/	 |
         | (1)------->(2)
         |      3	 */
        int [,] graph = new int[, ] {
            { 1, 1, 0, 1 },
            { 0, 1, 1, 0 },
            { 0, 0, 1, 1 },
            { 0, 0, 0, 1 }
        };

        // Print the solution
        GFG g = new GFG();

        g.transitiveClosure(graph);
    }
示例#3
0
文件: Format.cs 项目: xyLotus/TableIO
        private int[] GetLongestItem(Dictionary <string, string> givenDict)
        {
            List <int> keyLens = new List <int>();

            // Appending array with all the lengths of each key in array
            foreach (string element in givenDict.Keys)
            {
                keyLens.Add(element.Length);
            }

            // Appending array with all the lengths of each item in array
            List <int> valueLens = new List <int>();

            foreach (string value in givenDict.Values)
            {
                valueLens.Add(value.Length);
            }

            // Sorting List 'n stuff like that, ya get it
            GFG gg = new GFG();

            keyLens.Sort(gg);
            valueLens.Sort(gg);

            int[] longestElements = new int[2] {
                keyLens[keyLens.Count - 1], valueLens[valueLens.Count - 1]
            };

            // index[0] -> longest key; index[1] -> longest item;
            return(longestElements);
        }
示例#4
0
    public static void Main()
    {
        System.Console.WriteLine("Dijkstra Algorithm\n");

        // create a stopwatch
        // and start time
        var timer = new System.Diagnostics.Stopwatch();

        timer.Start();

        int[,] graph = new int[, ] {
            { 100, 344, 20, 40, 302, 70, 10, 68, 303 },
            { 4342, 34, 28, 30, 30, 30, 30, 11, 1430 },
            { 50, 8, 1340, 47, 670, 44, 40, 331, 242 },
            { 70, 232, 347, 320, 93, 124, 63, 406, 0 },
            { 40, 1230, 0, 9, 230, 10, 340, 320, 120 },
            { 80, 130, 434, 14, 10, 0, 322, 430, 340 },
            { 90, 40, 626, 560, 780, 232, 430, 12, 6 },
            { 28, 11, 32, 30, 103, 32, 211, 502, 347 },
            { 10, 40, 223, 230, 120, 650, 64, 457, 0 }
        };
        GFG t = new GFG();

        t.dijkstraAlgorithm(graph, 0);

        // stop stopwatch
        // and convert it to "second and split-second" based time
        timer.Stop();
        System.TimeSpan result = timer.Elapsed;
        System.Console.WriteLine("\nRuntime:" + result.ToString(@"ss\.ffff"));
        System.Console.WriteLine("\nPress Something to Exit");
        System.Console.ReadKey();
    }
示例#5
0
        private static List <int> GeneratePermutationFromNumberElements(int elements)
        {
            var intElements = new int[elements + 1];

            for (var i = 0; i <= elements; i++)
            {
                intElements[i] = i;
            }

            var t2 = new List <string>();

            for (var i = 0; i <= elements + 1; i++)
            {
                t2 = GFG.printCombination(intElements, elements + 1, i + 1);
            }

            var t3 = new List <int>();

            foreach (string s in t2)
            {
                t3.Add(int.Parse(s));
            }



            return(t3);
        }
    // Driver Code
    public static void Main(String [] args)
    {
        String str = "geeksforgeeks";
        GFG    r   = new GFG();

        r.removeDuplicates(str);
    }
示例#7
0
// Driver Code
    public static void Main(String[] args)
    {
        GFG tree = new GFG();

        int [] arr = { 5, 4, 7, 2, 11 };
        tree.treeins(arr);
        tree.inorderRec(tree.root);
    }
示例#8
0
    public static void Main(String[] args)
    {
        GFG ob   = new GFG();
        int sum1 = ob.Add(4, 5);

        Console.WriteLine("Sum of the two integer values: " + sum1);
        int sum2 = ob.Add(4, 5, 6);

        Console.WriteLine("Sum of the three interger values: " + sum2);
    }
示例#9
0
        public static void GetSolution(List <Nodes> node, int[,] matrix, int rootNode) //get the distance from the rootNode
        {
            int[] dist = GFG.dijkstra(matrix, rootNode, matrix.GetLength(0));
            int   V    = dist.Length;

            for (int i = 0; i < V; i++)
            {
                node[i].dist = dist[i];
            }
        }
示例#10
0
    // Driver Code
    public static void Main()
    {
        GFG arraysum = new GFG();

        int[] arr = { 15, 2, 4, 8, 9, 5, 10, 23 };
        int   n   = arr.Length;
        int   sum = 23;

        arraysum.subArraySum(arr, n, sum);
    }
示例#11
0
    public static void main(String[] args)
    {
        GFG ll = new GFG();

        for (int i = 5; i > 0; i--)
        {
            ll.push(head, i);
            ll.midpoint_util(head);
        }
    }
示例#12
0
        private string TryPermutation(string combination)
        {
            // string content = Get($"http://firstthreeodds.org/pdq?perm={combination}");

            GFG gfg = new GFG();

            return(Math.Abs(gfg.findRank(combination) - 200831837313463612).ToString());

            // return content;
        }
示例#13
0
            static void Main(string[] args)
            {
                int[,] graph = new int[, ] {
                    { 1, 1, 0, 1 },
                    { 0, 1, 1, 0 },
                    { 0, 0, 1, 1 },
                    { 0, 0, 0, 1 }
                };
                GFG g = new GFG();

                g.transitiveClosure(graph);
            }
// Driver Code
    public static void Main(String[] args)
    {
        GFG gfg = new GFG();

        gfg.initializeValues();

        // Calculate the Need Matrix
        gfg.calculateNeed();

        // Check whether system is in
        // safe state or not
        gfg.isSafe();
    }
示例#15
0
    // Driver Code
    public static void Main(string[] args)
    {
        GFG tree = new GFG();

        tree.root            = new Node(1);
        tree.root.left       = new Node(2);
        tree.root.right      = new Node(3);
        tree.root.left.left  = new Node(4);
        tree.root.left.right = new Node(5);

        Console.WriteLine("Level order traversal " + "of binary tree is ");
        tree.printLevelOrder();
    }
示例#16
0
    // Main Method
    public static void Main(String[] args)
    {
        // Creating Object
        GFG ob = new GFG();

        int sum2 = ob.Add(1, 2, 3);

        Console.WriteLine("sum of the three " + "integer value : " + sum2);

        double sum3 = ob.Add(1.0, 2.0, 3.0);

        Console.WriteLine("sum of the three " + "double value : " + sum3);
    }
示例#17
0
    // Main Method
    public static void Main(String[] args)
    {
        // Creating Object
        GFG ob = new GFG();

        int sum1 = ob.Add(1, 2);

        Console.WriteLine("sum of the two " + "integer value : " + sum1);


        int sum2 = ob.Add(1, 2, 3);

        Console.WriteLine("sum of the three " + "integer value : " + sum2);
    }
示例#18
0
    static public void Main()
    {
        int t = Convert.ToInt32(Console.ReadLine());

        GFG a = new GFG();

        for (int i = 0; i < t; i++)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[, ] graph = a.mountGraph(n);

            a.dijkstra(graph, n, 0);
        }
    }
示例#19
0
        public static void median()
        {
            List <int> numbers    = new List <int>(RnumbersInt());
            List <int> Newnumbers = new List <int>();
            // "gg" is the object oif class GFG
            GFG gg = new GFG();

            // method. The comparer is "gg"
            numbers.Sort(gg);

            foreach (int g in numbers)
            {
                Newnumbers.Add(g);
            }
            Console.WriteLine(Newnumbers[3]);
        }
    public static void Main(string[] args)
    {
        GFG tree = new GFG();

        tree.root                  = new Node(6);
        tree.root.left             = new Node(3);
        tree.root.right            = new Node(5);
        tree.root.right.right      = new Node(4);
        tree.root.left.left        = new Node(2);
        tree.root.left.right       = new Node(5);
        tree.root.left.right.right = new Node(4);
        tree.root.left.right.left  = new Node(7);

        Console.Write("Sum of all paths is " +
                      tree.treePathsSum(tree.root));
    }
示例#21
0
    // Driver Code
    public static void Main()
    {
        int[,] graph = new int[, ] {
            { 0, 4, 0, 0, 0, 0, 0, 8, 0 },
            { 4, 0, 8, 0, 0, 0, 0, 11, 0 },
            { 0, 8, 0, 7, 0, 4, 0, 0, 2 },
            { 0, 0, 7, 0, 9, 14, 0, 0, 0 },
            { 0, 0, 0, 9, 0, 10, 0, 0, 0 },
            { 0, 0, 4, 14, 10, 0, 2, 0, 0 },
            { 0, 0, 0, 0, 0, 2, 0, 1, 6 },
            { 8, 11, 0, 0, 0, 0, 1, 0, 7 },
            { 0, 0, 2, 0, 0, 0, 6, 7, 0 }
        };
        GFG t = new GFG();

        t.dijkstra(graph, 0);
    }
示例#22
0
    // Main method
    static void Main(string[] args)
    {
        // instance of string type
        GFG <string> name = new GFG <string>();

        name.value = "GeeksforGeeks";

        // instance of float type
        GFG <float> version = new GFG <float>();

        version.value = 5.0F;

        // display GeeksforGeeks
        Console.WriteLine(name.value);

        // display 5
        Console.WriteLine(version.value);
    }
        private static void GenericClassExampleOutput()
        {
            // instance of string type
            GFG <string> name = new GFG <string>();

            name.value = "GeeksforGeeks";

            // instance of float type
            GFG <float> version = new GFG <float>();

            version.value = 5.0F;

            // display GeeksforGeeks
            Console.WriteLine(name.value);

            // display 5
            Console.WriteLine(version.value);
        }
        private static List <string> GeneratePermutationFromNumberElements(int elements)
        {
            var intElements = new int[elements + 1];

            for (var i = 0; i <= elements; i++)
            {
                intElements[i] = i;
            }

            var t2 = new List <string>();

            for (var i = 0; i <= elements + 1; i++)
            {
                t2 = GFG.printCombination(intElements, elements + 1, i + 1);
            }


            return(t2);
        }
示例#25
0
文件: CoreMap.cs 项目: rvnbrz/D1
        public void CreateMap()
        {
            Events.Clear();
            List <Job> relatedJobs = Tasks.FindAll(x => ((x.CoreId == CoreID) && (x.CpuId == CpuID)));

            foreach (var job in relatedJobs)
            {
                foreach (var execution in job.ExecutionTrace)
                {
                    Events.Add(new Event(execution.Cycle, execution.ExecutionSize, job.Name, job.Cil));
                }
            }
            GFG gg = new GFG();

            Events.Sort(gg);
            CreateSeparateMap();
            CreateTaskMap();
            CreateSpaceMap();
        }
    // Driver Code
    public static void AlgoMain()
    {
        /* Let us create the example
         * graph discussed above */
        int[,] graph = new int[, ] {
            { 0, 4, 0, 0, 0, 0, 0, 8, 0 },
            { 4, 0, 8, 0, 0, 0, 0, 11, 0 },
            { 0, 8, 0, 7, 0, 4, 0, 0, 2 },
            { 0, 0, 7, 0, 9, 14, 0, 0, 0 },
            { 0, 0, 0, 9, 0, 10, 0, 0, 0 },
            { 0, 0, 4, 14, 10, 0, 2, 0, 0 },
            { 0, 0, 0, 0, 0, 2, 0, 1, 6 },
            { 8, 11, 0, 0, 0, 0, 1, 0, 7 },
            { 0, 0, 2, 0, 0, 0, 6, 7, 0 }
        };
        GFG t = new GFG();

        t.Dijkstra(graph, 0);
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                if (englishIn.Value != "")
                {
                    String EnglishChars = " abcdefghijklmnopqrstuvwxyz";
                    String str1         = englishIn.Value;
                    georgianOut.Value = GFG.conversion(EnglishChars, str1.ToCharArray());
                    //Console.Write(GFG.conversion("აბცდეფგჰიჯკლოპქრსტუვწხყზ", str1.ToCharArray()));
                }
                else
                {
                }
            }

            //String GeorgianChars = "აბცდეფგჰიჯკლმნოპქრსტუვწხყზ";
            //String str1 = englishIn.Value;
            //georgianOut.Value = GFG.conversion(GeorgianChars, str1.ToCharArray());
            //Console.Write(GFG.conversion("აბცდეფგჰიჯკლოპქრსტუვწხყზ", str1.ToCharArray()));
        }
示例#28
0
    public static void Main()
    {
        List <string> list1 = new List <string>();

        // list elements
        list1.Add("C++");
        list1.Add("Java");
        list1.Add("C");
        list1.Add("Python");
        list1.Add("HTML");
        list1.Add("CSS");
        list1.Add("Scala");
        list1.Add("Ruby");
        list1.Add("Perl");

        int range = 4;

        GFG gg = new GFG();

        Console.WriteLine("\nSort a range with comparer:");

        // sort the list within a
        // range of index 1 to 4
        // where range = 4
        list1.Sort(1, range, gg);

        Console.WriteLine("\nBinarySearch and Insert Dart");

        // Binary Search and storing
        // index value to "index"
        int index = list1.BinarySearch(0, range,
                                       "Dart", gg);

        if (index < 0)
        {
            list1.Insert(~index, "Dart");
            range++;
        }
    }
示例#29
0
    // Driver Code
    static public void Main(String[] args)
    {
        GFG tree = new GFG();

        tree.root             = new Node(1);
        tree.root.left        = new Node(2);
        tree.root.right       = new Node(2);
        tree.root.left.left   = new Node(3);
        tree.root.left.right  = new Node(4);
        tree.root.right.left  = new Node(4);
        tree.root.right.right = new Node(3);
        Boolean output = tree.isSymmetric(tree.root);

        if (output == true)
        {
            Console.WriteLine("1");
        }
        else
        {
            Console.WriteLine("0");
        }
    }
示例#30
0
        //
        public static string Dijkstra(List <string> vertex, int[,] graph, int vertexSize, int sampleSize, int sourcePoint)
        {
            // Driver Code
            GFG t = new GFG();

            t.Dijkstra(graph, sourcePoint, vertexSize);

            //
            string        integerFormat = @"00";
            StringBuilder status        = new StringBuilder();

            //
            for (int index = 0; index < t.dist.Length; index++)
            {
                // CORREGIR VALORES
                if (t.dist[index] >= Int32.MaxValue)
                {
                    t.dist[index] = 0;
                }

                //
                string separator = (index < (t.dist.Length - 1)) ? "," : string.Empty;
                //
                status.Append
                (
                    string.Format(@"{0}<{1}>-{2}-{3}{4}"
                                  , index.ToString(integerFormat)
                                  , vertex[index].Replace(",", ";").Replace("|", "")
                                  , t.dist[index].ToString(integerFormat)
                                  , t.path[index].Replace(",", ";")
                                  , separator
                                  )
                );
            }

            //
            return(status.ToString());
        }