Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //package profesjonal; Bartlomiej Wiewiora
- import java.io.*;
- import java.util.*;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.UnsupportedEncodingException;
- public class Profesjonal {
- public static void main(String[] args) {
- File fileDir = new File("opis.txt");
- try{
- BufferedReader in = new BufferedReader(
- new InputStreamReader(
- new FileInputStream(fileDir), "UTF8"));
- String str;
- int maxLength = 0;
- String najdl = "";
- while ((str = in.readLine()) != null) {
- String [] tab = str.split("[ .,\\-]");
- for(int d = 0; d < tab.length; d++){
- if (tab[d].length() > maxLength) {
- maxLength = tab[d].length();
- najdl = tab[d];
- }
- }
- }
- System.out.println(najdl);
- in.close();
- }
- catch (UnsupportedEncodingException e)
- {
- System.out.println(e.getMessage());
- }
- catch (IOException e)
- {
- System.out.println(e.getMessage());
- }
- catch (Exception e)
- {
- System.out.println(e.getMessage());
- }
- }
- }
- ////////////
- //package kolos2; Bartlomiej Wiewiora
- import java.io.*;
- import java.util.*;
- public class Kolos2
- {
- public static void main(String[] args) throws IOException
- {
- ArrayList<Integer> liczby = new ArrayList<Integer>();
- Scanner patrz = new Scanner(System.in);
- String nr = patrz.nextLine();
- String[] tab = nr.split("[ ]");
- for(int i = 0; i<tab.length; i++){
- liczby.add(Integer.parseInt(tab[i]));
- }
- Collections.sort(liczby);
- int siz = liczby.size();
- int od = siz-1;
- int dz = od/2;
- int med = liczby.indexOf(liczby.get(dz));
- System.out.println(liczby.get(med));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement