daily pastebin goal
39%
SHARE
TWEET

problema 2 java

ThePeeters Feb 23rd, 2018 77 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top