Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Intuit // C# // Lecture_4 // Laba_#2 _ZAD#2
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.IO; namespace Rextester { public class Program { //Functions public static double Left(double R, double x, ref double y) { y = R - Math.Sqrt(-(x*x) - 2*x*R); return y; } public static double Right(double R, double x, ref double y) { y = -R + Math.Sqrt(-(x*x) + 2*x*R); return y; } public static void Main(string[] args) { //Your code goes here //arguments /*выстрел снайпера должен попасть в цель (заштрихованная область) Y/b ^ | *|* | * | * | * | * | | | | | * | R *| R *---------+----------*+-----------+ * |\ *|===========| | \ =|===========| R| \ ==|===========|R * | \ *===|===========| * | \*=====|===========| *|*==========|===========| ------------+-----------+-----------+--------------> X/a |===========|========= *|* |===========|=====*\ | * |===========|===* \ | * R|===========|== \ |R |===========|= \ | |===========|* \| * +-----------+*----------+----------* R |* R | * | | | | | * | * | * | * | *|* | */ Console.WriteLine("LABA2_ZAD2"); double x=0,y=0, R=1; double a=0, b = 0; //выстрел снайпера (x:y) char L_R; //execution Console.WriteLine("enter radius R"); R = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("enter shoot coordinates a(x)"); a = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("enter shoot coordinates b(y)"); b = Convert.ToDouble(Console.ReadLine()); x=R; y=R; Console.WriteLine("R={0,3}; a={1,3}; b={2,3}", R,a,b); Console.WriteLine("R={0,3}; x={1,3}; y={2,3}", R,x,y); Console.WriteLine("-------------"); if (a<0 && b>-R && b<Left(R,a,ref y)) {Left(R,a,ref y); Console.WriteLine("Выстрел попал слева в цель: L_x= {0,1}, L_y= {1,1}",a,y);}//{L_R = 'L';} else {L_R='R';} else if (a>0 && b<R && b>Right(R,a,ref y)) {Right(R,a,ref b); Console.WriteLine("Выстрел попал справа в цель: R_x= {0,1}, R_y= {1,1}",a,y);} else {Console.WriteLine("MIMO");} } } }
run
|
edit
|
history
|
help
0
Reference Type parameter by Ref vs. Normal
from Base or Derived
The abstract factory design pattern implemented in c# using generics.
(Sort)Rounding Magic - C#
Helloworld
I have a small friend
recursive solution for subset sum
Inheritance
Demo
TEst