This commit is contained in:
Gašper Dobrovoljc 2024-03-18 22:47:09 +01:00
parent b7a5965a7d
commit a840b4eab6
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
3 changed files with 42 additions and 1 deletions

5
gesla.txt Normal file
View File

@ -0,0 +1,5 @@
4
abcdefghijklmnoprstuvz
XYQW
0123456789
_-#@

36
src/DN03.java Normal file
View File

@ -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);
}
}

View File

@ -2,7 +2,7 @@ public class Vaja02Fakulteta {
public static void main(String[] args) {
// izpisL();
// izpisD();
// izpisPiNilakantha();
// izpisPiNilakantha();
System.out.println(izracunajPi(5));
}