C.E/Java
max함수
숨[Breath]
2013. 10. 19. 09:56
public class pno5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int x[]={34,50,72,89,56};
int z=max(x);
System.out.println(z);
}
private static int max(int a[])
{
int b=0;
for(int i=0; i<a.length-1; i++){
if(i==0){
b=a[i];
}
if(b<a[i+1])
b=a[i+1];
}
return b;
}
}