static void Main(string[] args) { string x = " "; int j = 0; string line; // linia tekstu pobrana z pliku char[] sign = { ' ' }; //oddzielenie współrzędnych X i Y w linii vertex[] array = new vertex[1000]; do { int nr = 1; do { int counter = 0; if (x != " ") { array[0] = new vertex(); j = 1; string[] test2 = x.Split(sign); array[0].x = Convert.ToInt32(test2[0]); array[0].y = Convert.ToInt32(test2[1]); counter++; } for (int i = 0 + j; i <= 1000; i++) { line = Console.ReadLine(); if (line.Contains("--")) { break; } else { array[i] = new vertex(); string[] test2 = line.Split(sign); array[i].x = Convert.ToInt32(test2[0]); array[i].y = Convert.ToInt32(test2[1]); counter++; } } Console.WriteLine(nr++ + ". " + calculation(array, counter)); x = Console.ReadLine(); } while (!x.Contains("--")); x = Console.ReadLine(); }while (x != null); }
static int line_function(vertex A, vertex B, ref double a, ref double b, ref double c) { double a1 = (A.y - B.y); double a2 = (A.x - B.x); if (a2 == 0 && a1 == 0) //punkty pokrywające się { c = 123.456; return(0); } if (a2 == 0) //punkty o jednakowym x { b = 654.321; return(0); } a = (a1 / a2); b = B.y - (a * B.x); a = Math.Round(a, 6); b = Math.Round(b, 6); return(1); }