Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double x, y, x1, y1, x2, y2, x3, y3, r;
- try
- {
- for (; ; )
- {
- string[] str = Console.ReadLine().Split(new char[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < 6; ++i) str[i] = str[i].Replace('.', ',');
- x1 = double.Parse(str[0]);
- y1 = double.Parse(str[1]);
- x2 = double.Parse(str[2]);
- y2 = double.Parse(str[3]);
- x3 = double.Parse(str[4]);
- y3 = double.Parse(str[5]);
- x = ((y3 - y2) / 2 + (x1 - x3) * (x1 + x3) / 2 / (y1 - y3) - (x1 - x2) * (x1 + x2) / 2 / (y1 - y2)) / ((x1 - x3) / (y1 - y3) - (x1 - x2) / (y1 - y2));
- y = ((x3 - x2) / 2 + (y1 - y3) * (y1 + y3) / 2 / (x1 - x3) - (y1 - y2) * (y1 + y2) / 2 / (x1 - x2)) / ((y1 - y3) / (x1 - x3) - (y1 - y2) / (x1 - x2));
- if (x1 == x2) y = (y1 + y2) / 2;
- if (x1 == x3) y = (y1 + y3) / 2;
- if (y1 == y2) x = (x1 + x2) / 2;
- if (y1 == y3) x = (x1 + x3) / 2;
- r = Math.Sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
- string ans = "";
- if (Math.Abs(x) != 0) ans += "(";
- ans += "x";
- if (Math.Abs(x) != 0)
- {
- if (x >= 0) ans += " - ";
- else ans += " + ";
- ans += Math.Abs(x).ToString("0.000");
- ans += ")";
- }
- ans += "^2 + ";
- if (Math.Abs(y) != 0) ans += "(";
- ans += "y";
- if (Math.Abs(y) != 0)
- {
- if (y >= 0) ans += " - ";
- else ans += " + ";
- ans += Math.Abs(y).ToString("0.000");
- ans += ")";
- }
- ans += "^2 = ";
- ans += r.ToString("0.000");
- ans += "^2\n";
- ans += "x^2 + y^2 ";
- if (x != 0)
- {
- if (x < 0) ans += "+ ";
- else ans += "- ";
- ans += Math.Abs(2 * x).ToString("0.000");
- ans += "x ";
- }
- if (y != 0)
- {
- if (y < 0) ans += "+ ";
- else ans += "- ";
- ans += Math.Abs(2 * y).ToString("0.000");
- ans += "y ";
- }
- if (x * x + y * y - r * r != 0)
- {
- if (x * x + y * y - r * r > 0) ans += "+ ";
- else ans += "- ";
- ans += Math.Abs(x * x + y * y - r * r).ToString("0.000");
- ans += " ";
- }
- ans = ans.Replace(',', '.');
- ans += "= 0\n\n";
- Console.Write(ans);
- }
- }
- catch { return; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement