{"id":602,"date":"2024-01-09T19:15:26","date_gmt":"2024-01-09T19:15:26","guid":{"rendered":"https:\/\/javigomez.org\/?p=602"},"modified":"2025-09-29T20:33:44","modified_gmt":"2025-09-29T20:33:44","slug":"u06-07-funciones-para-dar-el-maximo-minimo-y-la-media-de-los-elementos-de-un-array","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/01\/09\/u06-07-funciones-para-dar-el-maximo-minimo-y-la-media-de-los-elementos-de-un-array\/","title":{"rendered":"U06-07-Funciones de m\u00e1ximo, m\u00ednimo y la media de los elementos de un array"},"content":{"rendered":"\n<p>Pedir por pantalla cuantos datos se van a escribir y preparar las siguientes funciones:<\/p>\n\n\n\n<p>Mostrar estos resultados por pantalla.<\/p>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex\">\n<p>static int maximo(int t[]): Se pasa la tabla y devuelve el valor m\u00e1ximo<\/p>\n\n\n\n<p>static int minimo(int t[]): Se pasa la tabla y devuelve el valor m\u00ednimo<\/p>\n\n\n\n<p>static double media(int t[]): Se pasa la tabla y devuelve el valor medio.<\/p>\n<\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>Java-U6-06-MutiplicadorArray\n\npackage U6;\n\nimport java.util.Arrays;\nimport java.util.Scanner;\n\npublic class A000 {\n\n\tpublic static void main(String&#91;] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.println(\"Cuantos elementos tiene el array?: \");\n\t\tint numeroEle= sc.nextInt();\n\t\t\n\t\tint numeros&#91;] = new int&#91;numeroEle];\n\t\t\n\t\tfor (int i=0;i&lt;numeros.length;i++) {\n\t\t\tSystem.out.println(\"Introduce el elemento \" + (i+1));\n\t\t\tnumeros&#91;i]=sc.nextInt();\n\t\t}\n\t\t\n\t\tmostrar(numeros);\n\t\t\n\t\tSystem.out.println(\"Multiplicador: \");\n\t\tint mult= sc.nextInt();\n\t\t\n\t\tint m&#91;]=multiplicador(numeros,mult);\n\t\t\n\t\tmostrar(m);\n\t\t\n\t\t\n\t\t\n\t}\n\n\tprivate static int&#91;] multiplicador(int&#91;] numeros, int mult) {\n\t\tint m&#91;] = new int&#91;numeros.length];\n\t\tfor (int i=0;i&lt;numeros.length;i++)\n\t\t\tm&#91;i]=numeros&#91;i]*mult;\n\t\treturn m;\n\t}\n\n\tprivate static void mostrar(int&#91;] numeros) {\n\t\tfor (int i=0;i&lt;numeros.length;i++) {\n\t\t\tSystem.out.println(\"Elemento \" + (i+1) +\":\" + numeros&#91;i]);\n\t\t}\n\t\t\n\t}\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Java U6 07 MaxMinMedArray\" width=\"1200\" height=\"900\" src=\"https:\/\/www.youtube.com\/embed\/snbVpZ7jcgg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Pedir por pantalla cuantos datos se van a escribir y preparar las siguientes funciones: Mostrar estos resultados por pantalla. static int maximo(int t[]): Se pasa &hellip; <\/p>\n","protected":false},"author":1,"featured_media":603,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[40,203],"class_list":["post-602","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-array","tag-java"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/comments?post=602"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/602\/revisions"}],"predecessor-version":[{"id":902,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/602\/revisions\/902"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/603"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}