{"id":1060,"date":"2025-12-05T16:37:23","date_gmt":"2025-12-05T16:37:23","guid":{"rendered":"https:\/\/javigomez.org\/?p=1060"},"modified":"2025-12-05T16:51:32","modified_gmt":"2025-12-05T16:51:32","slug":"evitar-repetidos","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2025\/12\/05\/evitar-repetidos\/","title":{"rendered":"Evitar repetidos"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">Pedir n\u00fameros por pantalla hasta que se escriba 0. Sacar la lista de n\u00fameros ordenada sin que haya repetidos.<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Tr02 {\n    public static void main(String&#91;] args) {\n                \/*\n        Pedir n\u00fameros por pantalla hasta que se escriba 0.\n        Sacar la lista de n\u00fameros ordenada sin que haya repetidos.\n         *\/\n\n        Scanner sc = new Scanner(System.in);\n        int numeros&#91;]=new int&#91;0];\n\n        System.out.println(\"Numero:\");\n        int num=sc.nextInt();\n\n        while (num!=0){\n            Arrays.sort(numeros);\n            int ind=Arrays.binarySearch(numeros,num);\n            if (ind&lt;0){\n                numeros=Arrays.copyOf(numeros,numeros.length+1);\n                numeros&#91;numeros.length-1]=num;\n            }\n            System.out.println(\"Numero:\");\n            num=sc.nextInt();\n        }\n        System.out.println(Arrays.toString(numeros));\n    }\n}\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=\"Evitar n\u00fameros repetidos\" width=\"1200\" height=\"900\" src=\"https:\/\/www.youtube.com\/embed\/RHqwGTyqU00?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 n\u00fameros por pantalla hasta que se escriba 0. Sacar la lista de n\u00fameros ordenada sin que haya repetidos.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[203],"class_list":["post-1060","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/1060","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=1060"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/1060\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/1060\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=1060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=1060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=1060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}