Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. public class Osoba {
  2.     private int[] tab={1,2,5,1,3,4,3,7,6};
  3.  
  4.     public Osoba (){
  5.  
  6.     }
  7.  
  8.     public int oblicz (int a, int b){
  9.         if(a>b)
  10.             return a;
  11.         else
  12.             return b;
  13.     }
  14.  
  15.     public void sort(){
  16.         int  pom;
  17.         for(int j=0; j<tab.length; j++){
  18.         for(int i = 0; i<tab.length-1; i++) {
  19.             if (tab[i] > tab[i + 1]) {
  20.                 pom = tab[i];
  21.                 tab[i] = tab[i + 1];
  22.                 tab[i + 1] = pom;
  23.  
  24.             }
  25.         }
  26.         }
  27.     }
  28.     public void wypisz(){
  29.         for(int i =0; i<tab.length; i++){
  30.             System.out.print(tab[i]+" ");
  31.         }
  32.     }
  33. }
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35.  
  36. public class test {
  37.     public static void main(String[] args) {
  38.         Osoba o = new Osoba();
  39.         System.out.println(o.oblicz(5,o.oblicz(10,15)));
  40.         o.sort();
  41.         o.wypisz();
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement