// PascalABC.NET // Версия 3.3.5 сборка 1662 (29.04.2018)
begin var b := ReadlnString('Введите строку -').ToLower+' '; var (z,r) := (',!?.:;'.ToCharArray,'!.?;'.ToCharArray); var tt:=true; Range(1,b.Length+b.ToCharArray.Where(t->t in z).Count).ForEach(t->if (b[t] in z) and tt then begin Insert(' ', b, t); tt:=false end else tt:=true); var a := b.ToWords; var x := ReadlnChar('Буква -'); var (w, i) := a.Select((w, i)-> (w, i)).Where(t -> t[0].ToString.First.ToLower = x).Reverse.UnZipTuple; i := i.Reverse; foreach var t in w.Zip(i, (p, q)-> (p, q)) do a[t[1]] := t[0]; b := string.Join(' ', a); tt:=true; Range(1,b.Length-b.ToCharArray.Where(t->t in z).Count+1).ForEach(t->if (b[t] in z) and tt then begin Delete(b, t - 1, 1); tt:=false end else tt:=true); b.Println; Println('Количество предложений:',b.ToWords(r).Count); end.
using System;
class Program
{
static void Main()
{
int x1 = 2, y1 = 1;
int x2 = 6, y2 = 5;
int x3 = 10, y3 = 1;
var a = Distance(x2, y2, x3, y3);
var b = Distance(x1, y1, x3, y3);
var c = Distance(x2, y2, x1, y1);
Console.WriteLine("S = {0}", Square(a, b, c));
Console.ReadKey();
}
//растояние между точками
static double Distance(int x1, int y1, int x2, int y2)
{
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
//формула герона
static double Square(double a, double b, double c)
{
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
// теорема косинусов
static double Angle(double a, double b, double c)
{
return Math.Acos((b * b + c * c - a * a) / (2 * b * c));
}
static bool IsAcuteAngel(double alpha)
{
return alpha < Math.PI / 2;
}
}