import java.util.Scanner ;
class Pessoa {
private static int idade;
public static String comparaIdade
( Pessoa
[ ] pessoa
) { int maior = pessoa[ 0 ] .idade ;
int indice = 0 ;
for ( int i = 1 ; i < 3 ; i++ ) {
if ( pessoa[ i] .idade > maior) {
maior = pessoa[ i] .idade ;
indice = i;
}
}
return pessoa[ indice] .nome ;
}
public static void main
( String [ ] args
) { Pessoa[ ] pessoa = new Pessoa[ 3 ] ;
Scanner input
= new Scanner
( System .
in ) ; for ( int i = 0 ; i< 3 ; i++ ) {
System .
out .
println ( "Digite o nome da pessoa: " ) ; pessoa[ i] .nome = input.nextLine ( ) ;
System .
out .
println ( "Digite a idade da pessoa: " ) ; pessoa[ i] .idade = input.nextInt ( ) ;
input.nextLine ( ) ;
}
System .
out .
printf ( "Nome da pessoa mais velha: %s" , comparaIdade
( pessoa
) ) ; }
}
//https://pt.stackoverflow.com/q/235770/101
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKY2xhc3MgUGVzc29hIHsKICAgIHByaXZhdGUgc3RhdGljIFN0cmluZyBub21lOwogICAgcHJpdmF0ZSBzdGF0aWMgaW50IGlkYWRlOwogICAgcHVibGljIHN0YXRpYyBTdHJpbmcgY29tcGFyYUlkYWRlKFBlc3NvYVtdIHBlc3NvYSkgewogICAgICAgIGludCBtYWlvciA9IHBlc3NvYVswXS5pZGFkZTsKICAgICAgICBpbnQgaW5kaWNlID0gMDsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8IDM7IGkrKykgewogICAgICAgICAgICBpZiAocGVzc29hW2ldLmlkYWRlID4gbWFpb3IpIHsKICAgICAgICAgICAgICAgIG1haW9yID0gcGVzc29hW2ldLmlkYWRlOwogICAgICAgICAgICAgICAgaW5kaWNlID0gaTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gcGVzc29hW2luZGljZV0ubm9tZTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKXsKICAgICAgICBQZXNzb2FbXSBwZXNzb2EgPSBuZXcgUGVzc29hWzNdOwogICAgICAgIFNjYW5uZXIgaW5wdXQgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpPDM7IGkrKykgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkRpZ2l0ZSBvIG5vbWUgZGEgcGVzc29hOiAiKTsKICAgICAgICAgICAgcGVzc29hW2ldLm5vbWUgPSBpbnB1dC5uZXh0TGluZSgpOwogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkRpZ2l0ZSBhIGlkYWRlIGRhIHBlc3NvYTogIik7CiAgICAgICAgICAgIHBlc3NvYVtpXS5pZGFkZSA9IGlucHV0Lm5leHRJbnQoKTsKICAgICAgICAgICAgaW5wdXQubmV4dExpbmUoKTsKICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGYoIk5vbWUgZGEgcGVzc29hIG1haXMgdmVsaGE6ICVzIiwgY29tcGFyYUlkYWRlKHBlc3NvYSkpOwogICAgfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8yMzU3NzAvMTAx