Thread for Programming and Realeted Topics

rclakmal

Active member
  • May 8, 2008
    698
    183
    43
    In a galaxy far far away
    Sry Bro ....Had lots of work this week !! So couldn't reply !!

    I gave a try !!

    Code:
    package example1;
    
    import java.util.LinkedList;
    import java.util.Random;
    import java.util.Scanner;
    import java.util.TreeSet;
    
    class Permutations {
    
        static LinkedList numbers = new LinkedList();
        static TreeSet permutations = new TreeSet();
        static Scanner input = new Scanner(System.in);
    
        public void getInput() {
            int i;
            do {
                System.out.println("Enter a negative number to stop entering the numbers");
                i = input.nextInt();
                if (i >= 0) {
                    numbers.add(i);
                }
            } while (i >= 0);
    
        }
    
        public void getPermutations() {
            Random r1 = new Random();
            int size = numbers.size();
            LinkedList tmpNumbers=new LinkedList();
            do {
                tmpNumbers.addAll(numbers);
                String s = "";
                int tmpRandom;
                while (tmpNumbers.size() > 0) {
                    tmpRandom = r1.nextInt(tmpNumbers.size());
                    s += "" + tmpNumbers.get(tmpRandom);
                    tmpNumbers.remove(tmpRandom);
                }
                permutations.add(s);
                
            } while (permutations.size() < calculateSize(size));
        }
    
        static int calculateSize(int number) {
            int fib = 1;
            for (int i = number; i > 0; i--) {
                fib *= i;
            }
            return fib;
        }
    
        public static void main(String[] args) {
            Permutations p1 = new Permutations();
            p1.getInput();
            System.out.println("You input =" + numbers);
            System.out.println("****Non Repeating Permutations****");
            p1.getPermutations();
            System.out.println(permutations);
        }
    }
     

    madurax86

    Member
    Jun 29, 2006
    4,385
    88
    0
    Sry Bro ....Had lots of work this week !! So couldn't reply !!

    I gave a try !!

    Code:
    package example1;
    
    import java.util.LinkedList;
    import java.util.Random;
    import java.util.Scanner;
    import java.util.TreeSet;
    
    class Permutations {
    
        static LinkedList numbers = new LinkedList();
        static TreeSet permutations = new TreeSet();
        static Scanner input = new Scanner(System.in);
    
        public void getInput() {
            int i;
            do {
                System.out.println("Enter a negative number to stop entering the numbers");
                i = input.nextInt();
                if (i >= 0) {
                    numbers.add(i);
                }
            } while (i >= 0);
    
        }
    
        public void getPermutations() {
            Random r1 = new Random();
            int size = numbers.size();
            LinkedList tmpNumbers=new LinkedList();
            do {
                tmpNumbers.addAll(numbers);
                String s = "";
                int tmpRandom;
                while (tmpNumbers.size() > 0) {
                    tmpRandom = r1.nextInt(tmpNumbers.size());
                    s += "" + tmpNumbers.get(tmpRandom);
                    tmpNumbers.remove(tmpRandom);
                }
                permutations.add(s);
                
            } while (permutations.size() < calculateSize(size));
        }
    
        static int calculateSize(int number) {
            int fib = 1;
            for (int i = number; i > 0; i--) {
                fib *= i;
            }
            return fib;
        }
    
        public static void main(String[] args) {
            Permutations p1 = new Permutations();
            p1.getInput();
            System.out.println("You input =" + numbers);
            System.out.println("****Non Repeating Permutations****");
            p1.getPermutations();
            System.out.println(permutations);
        }
    }
    ඔයා search කරල ඇඩ් කරනව වගේ එකක් තමා කරන්නේ result එක ආවාට random numbers පාවිච්චි කරන නිසා වෙලාව තමා ප්‍රශ්නය වෙන්නේ, ඒත් උත්සාහය හොදයි!
     

    rclakmal

    Active member
  • May 8, 2008
    698
    183
    43
    In a galaxy far far away
    ඔයා search කරල ඇඩ් කරනව වගේ එකක් තමා කරන්නේ result එක ආවාට random numbers පාවිච්චි කරන නිසා වෙලාව තමා ප්‍රශ්නය වෙන්නේ, ඒත් උත්සාහය හොදයි!

    Yr bro accept it !!!! :yes::yes::yes:
     

    madurax86

    Member
    Jun 29, 2006
    4,385
    88
    0
    Yr bro accept it !!!! :yes::yes::yes:

    net එකේ algorithm නම් තියෙනවා ගොඩාක් මං කීපයක් බැලුවා ගොඩක් ඒවා recursion මට වැඩි දුරට ඇත්තටම වෙන්නේ මොකක් ද කියලා ඔළුවට ගියේ නෑ පස්සේ වෙලාවක බලනවා ඔයත් ඕනා නම් බලන්න
     

    Konder

    Member
    Jan 14, 2010
    80
    0
    0
    UK
    What is the best program for downloading free music?

    Out of no where. I keep getting messages that pop up stating that my computer is infected, danger, attention, etc... then it tells you to download or continue unprotected. Uniblue does make a AntiSpyware for computers called Spy Eraser. However as this one appears to be legite, its comprimising my computer. After searching for the file I found it not as a program on the computer, but as a file in System32. Every two minutes those messages come up. I can not exit the program or disable it. It appears as if its a legitimate program, an icon on the bar next to the clock and one implanted on the desk top. However I ran all my spyware programs, anti-virus' programs and id failed to detect it. So I instaled MalwareBytes and it found it, and removed it. I ran it twice and everything else twice. Three hours later while the computer was siting, the message popped up. The icon reappeared on the desktop. The message continues every two minutes. Each message is similar but a little different from the rest. However it never changes its motive. I ran MalwareBytes again, it detected the infected files. So I did some research and found that I should use a program called RegCure to eliminate the rest of the files that were not being removed under the registry. It found 1242 infected files, and fixed them. However, I still find myself in the same boat. However I was told that I may not need to re-install the Windows, XP. Any suggestions before I move ahead on the reinstallation. unlock iphone 3g