Skip to content

Instantly share code, notes, and snippets.

@Vftdan
Created October 5, 2016 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vftdan/65dbdfe443f1d3db36c2101d1e65e7fc to your computer and use it in GitHub Desktop.
Save Vftdan/65dbdfe443f1d3db36c2101d1e65e7fc to your computer and use it in GitHub Desktop.
20161004.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cons161004
{
class Program
{
static void Main(string[] args)
{
var v = args.Length>0 ? int.Parse(args[0]) : 1;
var x = double.Parse(prompt("x"));
switch (v)
{
case 1: v1(x); break;
case 2: v2(x); break;
case 3: v3(x); break;
}
Console.ReadKey(true);
}
static void v1(double x)
{
double y;
if (x < -1) { y=(1.0); }
else
if (x < 0) { y=(0.3); }
else
if (x < 1) { y=(x*x); }
else { y=(1.0); }
writeln("y="+y);
}
static void v2(double x)
{
double y;
if (x < -1) { y = (0.0); }
else
if (x < 0) { y = (x+1.0); }
else
if (x < 1) { y = (x-1.0); }
else { y = (0.0); }
writeln("y=" + y);
}
static void v3(double x)
{
var y = double.Parse(prompt("y"));
var r = Math.Sqrt(x * x + y * y);
writeln("flag="+((r<=2&&r>=1&&x>=0)?1:0));
}
static string prompt(string s)
{
writeln("Введите "+s);
return Console.ReadLine();
}
static void writeln(string s)
{
Console.WriteLine(s);
}
static void writeln(object s)
{
writeln(s.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment