A11

import java.util.*;

public class Podpriemer {

        /**
         * @param args
         */

        public static void main(String[] args) {
                List<Integer> cisla = new ArrayList<Integer>();

                Scanner citac = new Scanner(System.in);
                while (citac.hasNextInt()) {
                        int cislo = citac.nextInt();
                        if (cislo < 0)
                                break;

                        cisla.add(new Integer(cislo));
                }

                int sucet = 0;
                for (int i = 0; i < cisla.size(); i++) {
                        int cislo = cisla.get(i);
                        sucet += cislo;
                }

                sucet = 0;
                for (int cislo : cisla) {
                        sucet += cislo;
                }

                double priemer = sucet / (double) cisla.size();

                List<Integer> podpriemerne = new ArrayList<Integer>();
                for (int cislo : cisla)
                        if (cislo < priemer)
                                podpriemerne.add(cislo);

                Collections.sort(podpriemerne);
                System.out.println(podpriemerne);
        }

}
import java.io.File;
import java.util.*;

public class Prednasky {

        public Set<String> citajRiadok(String riadok) {
                Set<String> vysledok = new HashSet<String>();
                Scanner citac = new Scanner(riadok);
                while (citac.hasNext()) {
                        vysledok.add(citac.next().toUpperCase());
                }

                return vysledok;
        }

        public Set<String> spolocnePrednasky(String subor) {
                Scanner citac = null;
                try {
                        citac = new Scanner(new File(subor));
                        while (citac.hasNextLine()) {
                                String riadok = citac.nextLine();
                                Set<String> prednaskyVRiadku = citajRiadok(riadok);
                                System.out.println(prednaskyVRiadku);
                        }
                } catch (Exception e) {
                        System.err.println("Zle je");
                } finally {
                        if (citac != null)
                                citac.close();
                }

                return null;
        }

        /**
         * @param args
         */

        public static void main(String[] args) {
                Prednasky prednasky = new Prednasky();
                System.out.println(prednasky.spolocnePrednasky("prednasky.txt"));
        }

}

import java.io.File;
import java.util.*;

public class Prednasky {

        public Set<String> citajRiadok(String riadok) {
                Set<String> vysledok = new HashSet<String>();
                Scanner citac = new Scanner(riadok);
                while (citac.hasNext()) {
                        vysledok.add(citac.next().toUpperCase());
                }

                return vysledok;
        }

        public Set<String> spolocnePrednasky(String subor) {
                Scanner citac = null;
                Set<String> vysledok = null;
                try {
                        citac = new Scanner(new File(subor));
                        while (citac.hasNextLine()) {
                                String riadok = citac.nextLine();
                                Set<String> prednaskyVRiadku = citajRiadok(riadok);
                                if (vysledok == null)
                                        vysledok = prednaskyVRiadku;
                                else
                                        vysledok.retainAll(prednaskyVRiadku);
                        }
                } catch (Exception e) {
                        System.err.println("Zle je");
                } finally {
                        if (citac != null)
                                citac.close();
                }

                return vysledok;
        }

        public Set<String> viacAkoPolovica(String subor) {
            Map<String, Integer> pocty = new HashMap<String, Integer>();
            int pocetStudentov = 0;

            // Pre kazdu prednasku zistime, kolko studentov ju navstevuje
            // vysledok ulozime do Map-u
                Scanner citac = null;
            try {
                    citac = new Scanner(new File(subor));
                    while (citac.hasNextLine()) {
                            String riadok = citac.nextLine();
                            Set<String> prednaskyVRiadku = citajRiadok(riadok);

                            // Zvysime pocitadla jednotlivych prednasok studenta
                            for (String prednaska: prednaskyVRiadku) {
                                if (pocty.containsKey(prednaska)) {
                                        pocty.put(prednaska, pocty.get(prednaska) + 1);
                                } else {
                                        pocty.put(prednaska, 1);
                                }
                            }

                            pocetStudentov++;
                    }
            } catch (Exception e) {
                    System.err.println("Zle je");
            } finally {
                    if (citac != null)
                            citac.close();
            }

            // Vyberieme z Map-u tie prednasky (kluce), ktore navstevuje viac ako polovica studentov
            Set<String> vysledok = new HashSet<String>();
            for (String prednaska: pocty.keySet())            
                if (pocty.get(prednaska) >= pocetStudentov/2)
                        vysledok.add(prednaska);

            return vysledok;
    }

        /**
         * @param args
         */

        public static void main(String[] args) {
                Prednasky prednasky = new Prednasky();
                System.out.println(prednasky.spolocnePrednasky("prednasky.txt"));
        }
}
import sk.upjs.umv.Zlomok;


public class Spustac {

        /**
         * @param args
         */

        public static void main(String[] args) {
                Zlomok z1 = new Zlomok(1, 2);
                Zlomok z2 = new Zlomok(2, 4);
                System.out.println(z1.toString());
                System.out.println(z1.equals(z2));
        }
}
package sk.upjs.umv;

public class Zlomok {
        private int citatel;
        private int menovatel;

        public Zlomok(int citatel, int menovatel) {
                this.citatel = citatel;
                this.menovatel = menovatel;

        }

        public int getCitatel() {
                return citatel;
        }

        public int getMenovatel() {
                return menovatel;
        }

        @Override
        public String toString() {
                return citatel + "/" + menovatel;
        }

        @Override
        public int hashCode() {
                return 0;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                Zlomok other = (Zlomok) obj;
                return citatel * other.menovatel == menovatel * other.citatel;
                /*
                if (citatel != other.citatel)
                        return false;
                if (menovatel != other.menovatel)
                        return false;
                return true;
                                */

        }


}