From 1fa69c1699127daba7cb2dd34885db395c417d25 Mon Sep 17 00:00:00 2001 From: iliya <iliya.saroukha@hes-so.ch> Date: Fri, 29 Sep 2023 16:42:49 +0200 Subject: [PATCH] tabtab --- serie1/Tableau.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 serie1/Tableau.java diff --git a/serie1/Tableau.java b/serie1/Tableau.java new file mode 100644 index 0000000..b42789d --- /dev/null +++ b/serie1/Tableau.java @@ -0,0 +1,25 @@ +public class Tableau { + + public static int countPositive(double[][] mat) { + int res = 0; + for (int i = 0; i < mat.length; i++) { + for (int j = 0; j < mat[i].length; j++) { + if (mat[i][j] > 0.0) { + res++; + } + } + } + return res; + } + + public static void main(String[] args) { + double[][] example = { + { 1.0, -2.0 }, + { 3.0 }, + { 1.5, -2.5, 3.0 } + }; + + int res = countPositive(example); + System.out.println("Count: " + res); + } +} -- GitLab