Skip to content

Instantly share code, notes, and snippets.

@Zulcom
Created April 25, 2015 18:29
Show Gist options
  • Save Zulcom/1df9d7bc35f8909614d5 to your computer and use it in GitHub Desktop.
Save Zulcom/1df9d7bc35f8909614d5 to your computer and use it in GitHub Desktop.
ПРограмма, которая выводит среднее кол-во сотрудников в одном подразделении данного учереждения. Входной формат <Surname> <Initials> <ph.nmbr>, отличия номеров разделов только в последних двух цифрах.
import java.util.*;
public class c4_5{
public static void main(String[] args){
Integer N = new Scanner(System.in).nextInt();
TreeSet<Integer> num = new TreeSet<>(); //treeset for exclude duplicates
for(int i = 0; i < N; i++) num.add(Integer.parseInt(new Scanner(System.in).nextLine().split(" ")[2].substring(7))); //parse to num only 2 last int
System.out.println(num.size()/N);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment