Advertisement
ThePeeters

problema 2 java

Feb 23rd, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import acm.program.ConsoleProgram;
  2.  
  3. /*
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8.  
  9. /**
  10. *
  11. * @author prb7
  12. */
  13. public class Problema2 extends ConsoleProgram{
  14. public int max(int[] numbers){
  15.  
  16. int max=0;
  17.  
  18. for(int i=0; i<numbers.length;++i){
  19. if(numbers[i]>max){
  20. max=numbers[i];
  21. }
  22. }
  23. return (max);
  24. }
  25.  
  26. public void run(){
  27. int[] nums = new int[] {4,12,-5,3};
  28. int max = max(nums);
  29. println("el resultat es " + max);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement