Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Task {
- public static final String name = "Sergey Shamov";
- public static double[][] points;
- public static int[] classes;
- public static double x;
- public static double y;
- public static double[][] normalized;
- public static double[] proximities;
- public static int resultClass;
- public static void main(String[] args) {
- Client.start();
- }
- public static void firstTask() {
- for (int i = 0; i < 50; i++) {
- normalized[i][0] = 0;
- normalized[i][1] = 0;
- }
- for (int i = 0; i < 50; i++) {
- double a = (y + 10)/(10 + 10);
- double q = (x + 1)/(1 + 1);
- normalized[i][0] = q;
- normalized[i][1] = a;
- }
- x = (x + 1) / 2;
- y = (y + 10) / 20;
- }
- public static void secondTask() {
- double[] distance = new double[50];
- for (int i = 0; i < 50; i++) {
- distance[i] = Math.sqrt(Math.pow(normalized[i][0] - x, 2) + Math.pow(normalized[i][1] - y, 2));
- }
- for (int i = 0; i < 50; i++) {
- double sumC = 1 / distance[i];
- proximities[classes[i]] += sumC;
- }
- }
- public static void thirdTask() {
- double max = Integer.MIN_VALUE;
- int index = 0;
- for (int i = 0; i < 3; i++) {
- if (proximities[i] > max) {
- max = proximities[i];
- index = i;
- }
- }
- resultClass = index;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement