/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
int [ ] idades = { 15 ,18 ,15 ,20 ,16 ,30 ,18 ,45 ,43 ,14 ,25 ,16 ,20 } ;
//contar
int [ ] contagemIdades = new int [ 200 ] ;
for ( int i = 0 ; i < idades.length ; ++ i) {
int idade = idades[ i] ;
contagemIdades[ idade] ++;
}
//mostrar
for ( int i = 0 ; i < contagemIdades.length ; ++ i) {
if ( contagemIdades[ i] >= 2 ) { //apenas as idades que tem mais que uma pessoa
System .
out .
printf ( "Existem %d pessoas com %d anos de idade\n " , contagemIdades
[ i
] , i
) ; }
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludFtdIGlkYWRlcyA9IHsxNSwxOCwxNSwyMCwxNiwzMCwxOCw0NSw0MywxNCwyNSwxNiwyMH07CgoJICAgICAgICAvL2NvbnRhcgoJICAgICAgICBpbnRbXSBjb250YWdlbUlkYWRlcyA9IG5ldyBpbnRbMjAwXTsKCSAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBpZGFkZXMubGVuZ3RoOyArK2kpewoJICAgICAgICAgICAgaW50IGlkYWRlID0gaWRhZGVzW2ldOwoJICAgICAgICAgICAgY29udGFnZW1JZGFkZXNbaWRhZGVdKys7CgkgICAgICAgIH0KCQoJICAg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