Advertisement
liwgfr

Untitled

Oct 27th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. public class Task {
  2.     public static final String name = "Sergey Shamov";
  3.  
  4.     public static double[][] points;
  5.     public static int[] classes;
  6.     public static double x;
  7.     public static double y;
  8.  
  9.     public static double[][] normalized;
  10.     public static double[] proximities;
  11.     public static int resultClass;
  12.  
  13.     public static void main(String[] args) {
  14.         Client.start();
  15.     }
  16.     public static void firstTask() {
  17.         normalized = new double[50][2];
  18.         for (int i = 0; i < 50; i++) {
  19.             normalized[i][0] = 0;
  20.             normalized[i][1] = 0;
  21.         }
  22.  
  23.         for (int i = 0; i < 50; i++) {
  24.             double a = (y + 10)/(10 + 10);
  25.             double q = (x + 1)/(1 + 1);
  26.             normalized[i][0] = q;
  27.             normalized[i][1] = a;
  28.         }
  29.  
  30.         x = (x + 1) / 2;
  31.         y = (y + 10) / 20;
  32.     }
  33.  
  34.     public static void secondTask() {
  35.         double[] distance = new double[50];
  36.         for (int i = 0; i < 50; i++) {
  37.             distance[i] = Math.sqrt(Math.pow(normalized[i][0] - x, 2) + Math.pow(normalized[i][1] - y, 2));
  38.         }
  39.         for (int i = 0; i < 50; i++) {
  40.             double sumC = 1 / distance[i];
  41.             proximities[classes[i]] += sumC;
  42.         }
  43.     }
  44.  
  45.     public static void thirdTask() {
  46.         double max = Integer.MIN_VALUE;
  47.         int index = 0;
  48.         for (int i = 0; i < 3; i++) {
  49.             if (proximities[i] > max) {
  50.                 max = proximities[i];
  51.                 index = i;
  52.             }
  53.         }
  54.         resultClass = index;
  55.     }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement