• API
• FAQ
• Tools
• Archive
daily pastebin goal
53%
SHARE
TWEET

# Untitled

a guest Apr 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import javax.swing.*;
2. public class CreaAnagrammi
3.  {
4.    public static void main (String[] args)
5.     {
6.      String stringa = JOptionPane.showInputDialog("Inserisci la stringa");
7.      char[] stringavet = stringa.toCharArray();
8.      char scambio = 0;
9.      int n = stringavet.length, fatt = 1, i = 0;
10.      String[] anagrammi = new String[n];
11.      boolean continua = true;
12. //Istanzazione vettore
13.      for(i=0;i<=anagrammi.length-1;i++)
14.        anagrammi[i] = "";
15. //Calcolo fattoriale
16.      for (int j=0;j<stringavet.length;j++)
17.        fatt *= (n-j);
18.      System.out.println("Il ciclo verrĂ  eseguito per "+fatt+" volte.");
19.
20. //Calcolo anagrammi
21.      for(int j=0;j<stringavet.length-1;j++)
22.        {
23.         scambio = stringavet[j];
24.         stringavet[j] = stringavet[j+1];
25.         stringavet[j+1] = scambio;
26.         for (int k=0;k!=stringavet.length;k++)
27.          anagrammi[i] += stringavet[k];
28.         i++;
29.         System.out.println("ciao");
30.        }
31.
32.       for(int j=stringavet.length;j==0;j--)
33.        {
34.         scambio = stringavet[j];
35.         stringavet[j] = stringavet[j-1];
36.         stringavet[j-1] = scambio;
37.         for (int k=0;k!=stringavet.length;k++)
38.          anagrammi[i] += stringavet[k];
39.         i++;
40.        }
41.
42. //Stampa valori
43.      for(i=0;i<anagrammi.length;i++)
44.       System.out.println(anagrammi[i]);
45.     }
46.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top