diff --git a/gesla.txt b/gesla.txt new file mode 100644 index 0000000..c1a7ce6 --- /dev/null +++ b/gesla.txt @@ -0,0 +1,5 @@ +4 +abcdefghijklmnoprstuvz +XYQW +0123456789 +_-#@ \ No newline at end of file diff --git a/src/DN03.java b/src/DN03.java new file mode 100644 index 0000000..e550ee7 --- /dev/null +++ b/src/DN03.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Random; +import java.util.Scanner; + +public class DN03 { + public static void main(String[] args) { + File file = new File(args[0]); + Scanner scanner; + try { + scanner = new Scanner(file); + } catch (FileNotFoundException e) { + System.err.println("Datoteka ne obstaja"); + return; + } + + int len = Integer.parseInt(scanner.nextLine()); + String[] besede = new String[len]; + + for (int i = 0; i < len; i++) { + besede[i] = scanner.nextLine(); + } + scanner.close(); + + int n = Integer.parseInt(args[1]); + Random random = new Random(Integer.parseInt(args[2])); + + StringBuilder geslo = new StringBuilder(); + for (int i = 0; i < n; i++) { + String beseda = besede[random.nextInt(len)]; + geslo.append(beseda.charAt(random.nextInt(beseda.length()))); + } + + System.out.println(geslo); + } +} diff --git a/src/Vaja02Fakulteta.java b/src/Vaja02Fakulteta.java index 98fea16..70d84da 100644 --- a/src/Vaja02Fakulteta.java +++ b/src/Vaja02Fakulteta.java @@ -2,7 +2,7 @@ public class Vaja02Fakulteta { public static void main(String[] args) { // izpisL(); // izpisD(); -// izpisPiNilakantha(); + // izpisPiNilakantha(); System.out.println(izracunajPi(5)); }