Advertisement
Mancolo

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

May 5th, 2021
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. package com.company;
  2. import java.util.*;
  3. public class Solution {
  4.     public static void main(String[] args) {
  5.         Scanner in = new Scanner(System.in);
  6.         System.out.println("===Первое заданиие===");
  7.         System.out.println("Enter word:");
  8.         String qwe = in.next();
  9.         int l = qwe.length();
  10.         ArrayList<String> asd = new ArrayList<String>();
  11.         while (asd.size() != (int) (Math.pow(l, l))) {
  12.             String z = "";
  13.             for (int j = 0; j < l; j++) {
  14.                 z += qwe.charAt(0 + (int) (Math.random() * l));
  15.             }
  16.             if (asd.contains(z)) continue;
  17.             else asd.add(z);
  18.         }
  19.         for (String x : asd) {
  20.             System.out.println(x);
  21.         }
  22.  
  23.         System.out.println("===Второе заданиие===");
  24.         String y = in.nextLine();
  25.         String[] e = y.split(" ");
  26.         for (int i = e.length - 1; i >= 0; i--) {
  27.             System.out.print(e[i] + " ");
  28.         }
  29.  
  30.  
  31.         System.out.println("===Третье заданиие===");
  32.         HashSet<Character> v = new HashSet<Character>();
  33.         String r = in.nextLine();
  34.         char[] a = r.toCharArray();
  35.         for (char i : a) {
  36.             v.add(i);
  37.         }
  38.         for (char i : v) {
  39.             System.out.print(i);
  40.         }
  41.  
  42.  
  43.         System.out.println("===Четвертое заданиие===");
  44.         int[] sd = {1, 2, 3, 4, 43, 34, 5, 134, 43, 62, 3, 3};
  45.         Arrays.sort(sd);
  46.         for (int i : sd) {
  47.             System.out.println(i);
  48.         }
  49.  
  50.  
  51.         System.out.println("===Пятое заданиие===");
  52.         Map map = new HashMap();
  53.         map.put(1, "один");
  54.         map.put(2, "два");
  55.         map.put(3, "три");
  56.         int sum = 0;
  57.         for (Object i : map.keySet()) {
  58.             sum += Integer.parseInt(i.toString());
  59.         }
  60.     }
  61. }
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement