From 12a2fa369bebf06753654ae56d607465419b0553 Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Sun, 05 Oct 2025 17:46:24 +0200
Subject: [PATCH] alcuni esercizi con array

---
 src/main/java/CouponCollector.java |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/main/java/CouponCollector.java b/src/main/java/CouponCollector.java
new file mode 100644
index 0000000..9c15a48
--- /dev/null
+++ b/src/main/java/CouponCollector.java
@@ -0,0 +1,19 @@
+public class CouponCollector {
+    public static void main(String[] args) {
+        int n = Integer.parseInt(args[0]);
+        boolean[] trovato = new boolean[n];
+        int distinti = 0;
+        int tentativi = 0;
+
+        while (distinti < n) {
+            int r = (int) (Math.random() * n);
+            tentativi++;
+            if (!trovato[r]) {
+                trovato[r] = true;
+                distinti++;
+            }
+        }
+
+        System.out.println(tentativi + " tentativi");
+    }
+}

--
Gitblit v1.8.0