lety_ciaPosts:2
Publicado em: 26/06/2011 09:58:37
Estou tentando fazer o seguinte, ler uma matriz com 16 valores, mostrar os valores e quantos vezes se repete. Comecei assim: int matriz[] = new int[16]; int num = 0,maior = 0; String num1, res = ""; for (int i = 0; i < matriz.length; i++) { num1 = JOptionPane.showInputDialog("digite o valor:"); num = Integer.parseInt(num1); matriz = num; } for (int i = 1; i < matriz.length; i += 2) { if (matriz > maior) { maior = matriz; }} for (int i = 0; i < matriz.length; i++) { res = res + " " + matriz + "\n"; } JOptionPane.showMessageDialog(null, res+"maior "+maior); }}
sekkuarPosts:5998
Publicado em: 26/06/2011 12:42:27
facil. você ja descobriu qual é o maior, certo? Faz um contador. int contador = 0; Faz um for para percorrer a matriz e um if if(matriz==maior) contador++; _________________Sekkuar ~ Ex-Catador Executivo do Javafree - (Não mais) Catando os tópico tudo. "The mod javafree deserves, but not the one it needs right now."
StackTraces p/ Noobs Stack Traces existem pra ajudar e não para trazer uma mensagem de satã dizendo que seu computador será destruído. Peça seu Código Pronto para o seu Dever de Casa aqui You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility. lety_ciaPosts:2 Publicado em: 26/06/2011 09:58:37 Muito obrigada Relacionados [RESOLVIDO] JButton do windowshttp://javafree.uol.com.br/topic-890657-RESOLVIDO-JButton-do-windows.htmlConsultar valor determinadohttp://javafree.uol.com.br/topic-890688-Consultar-valor-determinado.htmlUm arraylist dentro de outro arrayliste e relacionar os dadohttp://javafree.uol.com.br/topic-890627-Um-arraylist-dentro-de-outro-arrayliste-e-relacionar-os-dado.htmlAjuda com Vendashttp://javafree.uol.com.br/topic-890690-Ajuda-com-Vendas.htmlDúvida com Padrões de Projeto - Permissões.http://javafree.uol.com.br/topic-890664-Duvida-com-Padroes-de-Projeto-Permissoes.html
Peça seu Código Pronto para o seu Dever de Casa aqui You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
Muito obrigada
Relacionados
[RESOLVIDO] JButton do windowshttp://javafree.uol.com.br/topic-890657-RESOLVIDO-JButton-do-windows.htmlConsultar valor determinadohttp://javafree.uol.com.br/topic-890688-Consultar-valor-determinado.htmlUm arraylist dentro de outro arrayliste e relacionar os dadohttp://javafree.uol.com.br/topic-890627-Um-arraylist-dentro-de-outro-arrayliste-e-relacionar-os-dado.htmlAjuda com Vendashttp://javafree.uol.com.br/topic-890690-Ajuda-com-Vendas.htmlDúvida com Padrões de Projeto - Permissões.http://javafree.uol.com.br/topic-890664-Duvida-com-Padroes-de-Projeto-Permissoes.html
lety_ciaPosts:2
Estou tentando fazer o seguinte, ler uma matriz com 16 valores, mostrar os valores e quantos vezes se repete. Comecei assim:
sekkuarPosts:5998
facil.
você ja descobriu qual é o maior, certo?
Faz um contador.
Faz um for para percorrer a matriz e um if
_________________Sekkuar ~ Ex-Catador Executivo do Javafree - (Não mais) Catando os tópico tudo.
"The mod javafree deserves, but not the one it needs right now."