Advertisement
Guest User

Untitled

a guest
May 28th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace Ingres
  13. {
  14.     class Point
  15.     {
  16.         double x;
  17.         double y;
  18.         bool[] Connection;
  19.         public Point(double x,double y,bool[]Connections)
  20.         {
  21.             this.x = x;
  22.             this.y = y;
  23.             for(int i=0;i<Connections.Length;i++)
  24.             {
  25.                 Connection[i] = Connections[i];
  26.             }
  27.         }
  28.         public double getX()
  29.         {
  30.              return x;
  31.         }
  32.         public double getY()
  33.         {
  34.             return y;
  35.         }
  36.     }
  37.     public partial class Form1 : Form
  38.     {
  39.         public Form1()
  40.         {
  41.             InitializeComponent();
  42.         }
  43.         public void Input(out int[] Array_Out_X, out int[] Array_Out_Y)
  44.         {
  45.             string[] x = File.ReadAllText("portals1.csv").Split(';');
  46.             double[] Arrayx;
  47.             double[] Arrayy;
  48.             int sizeOfTheInput = x.GetLength(0);
  49.  
  50.             sizeOfTheInput--;
  51.             if (sizeOfTheInput % 2 == 0)
  52.             {
  53.                 Arrayx = new double[sizeOfTheInput / 2];
  54.                 Arrayy = new double[sizeOfTheInput / 2];
  55.                 Array_Out_X = new int[sizeOfTheInput / 2];
  56.                 Array_Out_Y = new int[sizeOfTheInput / 2];
  57.             }
  58.             else
  59.             {
  60.                 Arrayx = new double[sizeOfTheInput / 2 + 1];
  61.                 Arrayy = new double[sizeOfTheInput / 2 + 1];
  62.                 Array_Out_Y = new int[sizeOfTheInput / 2 + 1];
  63.                 Array_Out_X = new int[sizeOfTheInput / 2+1];
  64.             }
  65.  
  66.             for (int i = 2, j = 0; j < x.GetLength(0); i = i + 2, j++)
  67.             {
  68.                 try
  69.                 {
  70.                     Arrayy[j] = Convert.ToDouble(x[i].Split('\r')[0]);
  71.                 }
  72.                 catch { };
  73.             }
  74.             for (int i = 1, j = 0; j < x.GetLength(0); i = i + 2, j++)
  75.             {
  76.                 try
  77.                 {
  78.                     Arrayx[j] = Convert.ToDouble(x[i].Split('\r')[0]);
  79.                 }
  80.                 catch { };
  81.             }
  82.             //Нормализация
  83.             double minX = FindMin(Arrayx);
  84.             double minY=FindMin(Arrayy);
  85.             for (int i = 0; i < Arrayx.Length; i++)
  86.             {
  87.                
  88.                 Array_Out_X[i] = Convert.ToInt32((Arrayx[i] - minX) * 100000);
  89.             }
  90.             for (int i = 0; i < Arrayy.Length; i++)
  91.             {
  92.                
  93.                Array_Out_Y[i] = Convert.ToInt32((Arrayy[i] - minY) * 100000);
  94.             }
  95.         }
  96.         public double FindMin(double []Array)
  97.         {
  98.             double min = 100000;
  99.             for(int i=0;i<Array.Length;i++)
  100.             {
  101.                 if (min > Array[i])
  102.                     min = Array[i];
  103.             }
  104.             return min;
  105.         }
  106.         private void Form1_Load(object sender, EventArgs e)
  107.         {
  108.  
  109.             int[] Arrayx;
  110.             int[] Arrayy;
  111.             Input(out Arrayx, out Arrayy);
  112.            
  113.            
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement