Advertisement
liwgfr

Untitled

Oct 27th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 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.         for (int i = 0; i < 50; i++) {
  18.             normalized[i][0] = 0;
  19.             normalized[i][1] = 0;
  20.         }
  21.  
  22.         for (int i = 0; i < 50; i++) {
  23.             double a = (y + 10)/(10 + 10);
  24.             double q = (x + 1)/(1 + 1);
  25.             normalized[i][0] = q;
  26.             normalized[i][1] = a;
  27.         }
  28.        
  29.         x = (x + 1) / 2;
  30.         y = (y + 10) / 20;
  31.     }
  32.  
  33.     public static void secondTask() {
  34.         double[] distance = new double[50];
  35.         for (int i = 0; i < 50; i++) {
  36.             distance[i] = Math.sqrt(Math.pow(normalized[i][0] - x, 2) + Math.pow(normalized[i][1] - y, 2));
  37.         }
  38.         for (int i = 0; i < 50; i++) {
  39.             double sumC = 1 / distance[i];
  40.             proximities[classes[i]] += sumC;
  41.         }
  42.     }
  43.  
  44.     public static void thirdTask() {
  45.         double max = Integer.MIN_VALUE;
  46.         int index = 0;
  47.         for (int i = 0; i < 3; i++) {
  48.             if (proximities[i] > max) {
  49.                 max = proximities[i];
  50.                 index = i;
  51.             }
  52.         }
  53.         resultClass = index;
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement