using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SpeedTestCs { class Aux { public double x, y, z; double Sfera { get { return x*x + y*y + z*z; } } double XPlaneFunc { get { return x;} } double YPlaneFunc { get { return y;} } double ZZZFunc() { double xmy = x - y; return xmy - Math.Round(xmy, 1); } double Spiral_() { double xk=x*20; double a=0.2; double b=1.5; double y1=y*b-a*Math.Sin(xk); double z1=z*b-a*Math.Cos(xk); return y1*y1 + z1*z1; } public bool Golova() { return XPlaneFunc < 0.0 && Sfera < 1.0 && !Shliz(); } bool Spiral() { return XPlaneFunc > 0.0 && XPlaneFunc < 1.75 && Math.Abs(Spiral_()) < 0.5; } bool Shliz() { return XPlaneFunc < -0.4 && YPlaneFunc < 0.1 && YPlaneFunc > -0.1; } bool Strokes() { return (Math.Abs(0.5 - XPlaneFunc) < 0.02 || (XPlaneFunc > 0.5 && Math.Abs(ZZZFunc()) < 0.005)) && !Spiral() && !Golova(); } bool Wall() { return XPlaneFunc > 0.5 && !Strokes() && !Spiral(); } public int GetColor() { if ( Golova() ) return 1; if ( Spiral() ) return 2; if ( Strokes() )return 3; if ( Wall() ) return 4; return 0; } }; class Program { static void Main(string[] args) { Aux a = new Aux(); DateTime t1 = DateTime.Now; for(int i = 0; i < 100; i++) { a.z = 0; for(a.y = -1.5; a.y < 1.5; a.y += 0.001) { for(a.x = -1; a.x < 2; a.x += 0.001) { int c = a.GetColor(); } } } DateTime t2 = DateTime.Now; Console.WriteLine("Elapsed {0} sec.\n", t2-t1); } } }