Advertisement
Mancolo

Домашняя работа

May 5th, 2021
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. Scanner in = new Scanner(System.in);
  2.         // 1
  3.         System.out.println("Enter word:");
  4.         String qwe = in.next();
  5.         int l = qwe.length();
  6.         ArrayList<String> asd = new ArrayList<String>();
  7.             while (asd.size() != (int) (Math.pow(l,l))){
  8.                 String z = "";
  9.                 for (int j = 0; j < l; j++) {
  10.                     z += qwe.charAt(0 + (int) (Math.random() * l)); }
  11.                 if( asd.contains(z)) continue;
  12.                 else asd.add(z); }
  13.         for (String x: asd) { System.out.println(x); }
  14.  
  15. //2
  16.         String y = in.nextLine();
  17.         String[] e = y.split(" ");
  18.         for (int i = e.length-1; i >= 0; i--) {
  19.             System.out.print(e[i] + " "); }
  20.  
  21.        
  22.         // 3
  23.         HashSet<Character> v = new HashSet<Character>();
  24.         String r = in.nextLine();
  25.         char[] a = r.toCharArray();
  26.         for (char i : a) {
  27.             v.add(i); }
  28.         for (char i: v) {
  29.             System.out.print(i); }
  30.  
  31.        
  32.         //4
  33.         int[] sd = {1,2,3,4,43,34,5,134,43,62,3,3};
  34.         Arrays.sort(sd);
  35.         for (int i: sd) {
  36.             System.out.println(i); }
  37.  
  38.  
  39. //5
  40.         Map map = new HashMap();
  41.         map.put(1, "один");
  42.         map.put(2, "два");
  43.         map.put(3, "три");
  44.         int sum = 0;
  45.         for( Object i : map.keySet()){
  46.             sum += Integer.parseInt(i.toString()); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement