DN03
This commit is contained in:
parent
b7a5965a7d
commit
a840b4eab6
36
src/DN03.java
Normal file
36
src/DN03.java
Normal 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);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ public class Vaja02Fakulteta {
|
|||
public static void main(String[] args) {
|
||||
// izpisL();
|
||||
// izpisD();
|
||||
// izpisPiNilakantha();
|
||||
// izpisPiNilakantha();
|
||||
System.out.println(izracunajPi(5));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user