示例#1
0
        public static void PA()
        {
            LinkedList2 a = new LinkedList2();


            for (int i = 2; i <= 1000; i++)
            {
                if (isprimeNo(i) == true)
                {
                    a.Add(i);
                }
            }
            a.Display();
            Console.WriteLine("_________________________________________");
            a.Aaanna();
        }
示例#2
0
        //anagram logic

        public void Aaanna()
        {
            PrimeAnagram1 pp = new PrimeAnagram1();
            LinkedList2   b  = new LinkedList2();

            LinkedList2 c    = new LinkedList2();
            LinkedList2 d    = new LinkedList2();
            Node11      temp = head;

            while (temp != null)
            {
                //at first temp.data go to anagram method
                Node11 n = head;
                while (n != null)
                {
                    //i have used 2 loops for anagram and
                    if (PrimeAnagram1.Anagram(temp.data, n.data) == true)
                    {
                        //add the data in linked list
                        b.Add(temp.data);
                        //add the data into the queue
                        c.AddinStake(temp.data);
                        //add the linked list using queue
                        d.AddiQueue(temp.data);
                        break;
                    }



                    n = n.next;
                }
                temp = temp.next;
            }
            Console.WriteLine("prime and anagram................>");
            b.Display();
            Console.WriteLine("prime and anagram in reverse order using stack................>");
            c.Display();
            Console.WriteLine("prime and anagram in using queue................>");
            d.Display();
        }