ЛС
Лана Сепик

нужно переделать код с паскаля на си шарп

Программа определяет, какую из осей пересекает
отрезок, соединяющий две точки
program hr;

var x1,y1,x2,y2:real;
da:boolean;

begin
write('Vvedite X1 dlia tociki A: '); readln(x1);
write('Vvedite Y1 dlia tociki A: '); readln(y1);

write('Vvedite X2 dlia tociki B: '); readln(x2);
write('Vvedite Y2 dlia tociki B: '); readln(y2);

writeln; writeln('A(',x1:0:2,',',y1:0:2,') & ','B(',x2:0:2,',',y2:0:2,')'); writeln;
da:=false;
if (x1>0) and(y1>0) and(x2<0) and(y2>0) then begin writeln('peresekaet osi "OY"'); da:=true;end;
if (x1>0) and(y1>0) and(x2<0) and(y2<0) then begin writeln('peresekaet osi "XY"'); da:=true;end;
if (x1>0) and(y1>0) and(x2>0) and(y2<0) then begin writeln('peresekaet osi "OX"'); da:=true;end;
if (x1<0) and(y1>0) and(x2<0) and(y2<0) then begin writeln('peresekaet osi "OX"'); da:=true;end;
if (x1<0) and(y1>0) and(x2>0) and(y2<0) then begin writeln('peresekaet osi "XY"'); da:=true;end;
if (x1<0) and(y1<0) and(x2>0) and(y2<0) then begin writeln('peresekaet osi "OY"'); da:=true;end;

if (x1<0) and(y1>0) and(x2>0) and(y2>0) then begin writeln('peresekaet osi "OY"'); da:=true;end;
if (x1<0) and(y1<0) and(x2>0) and(y2>0) then begin writeln('peresekaet osi "XY"'); da:=true;end;
if (x1>0) and(y1<0) and(x2>0) and(y2>0) then begin writeln('peresekaet osi "OX"'); da:=true;end;
if (x1<0) and(y1<0) and(x2<0) and(y2>0) then begin writeln('peresekaet osi "OX"'); da:=true;end;
if (x1>0) and(y1<0) and(x2<0) and(y2>0) then begin writeln('peresekaet osi "XY"'); da:=true;end;
if (x1>0) and(y1<0) and(x2<0) and(y2<0) then begin writeln('peresekaet osi "OY"'); da:=true;end;

if not da then writeln('Eti tociki ne peresekaiyt ni odny osi');

readln;
end.

Кр
Кристина

using System;
namespace example
{
class Program
{
struct Coord { public double x; public double y; }

static void Main(string[] args)
{
Coord p1, p2;

while (true)
{
Console.Write("Введите координату x1: "); p1.x = Convert.ToDouble(Console.ReadLine());
Console.Write("Введите координату y1: "); p1.y = Convert.ToDouble(Console.ReadLine());
Console.Write("Введите координату x2: "); p2.x = Convert.ToDouble(Console.ReadLine());
Console.Write("Введите координату y2: "); p2.y = Convert.ToDouble(Console.ReadLine());

Crossing(p1, p2);

Console.ReadLine();
}
}

static void Crossing(Coord p1, Coord p2)
{
if (p1.x == p2.x && p1.y == p2.y) { Console.WriteLine("Отрезок не существует"); return; }
if (p1.x + p2.x == 0 && p1.y + p2.y == 0) { Console.WriteLine("Отрезок проходит через оси координат"); return; }
if (p1.x * p2.x < 0) Console.WriteLine("Отрезок пересекает ось OY");
if (p1.y * p2.y < 0) Console.WriteLine("Отрезок пересекает ось OX");
if (p1.x * p2.x > 0 && p1.y * p2.y > 0) Console.WriteLine("Отрезок не пересекает оси координат");
if (p1.x == 0 && p2.x == 0) Console.WriteLine("Отрезок лежит на оси OY");
else if (p1.x * p2.x == 0) Console.WriteLine("Отрезок касается оси OY");
if (p1.y == 0 && p2.y == 0) Console.WriteLine("Отрезок лежит на оси OX");
else if (p1.y * p2.y == 0) Console.WriteLine("Отрезок касается оси OX");
}
}
}

Ta
Talant

я дурак, Ю мне делать нечего
double x1,y1,x2,y2:real;
bool da;

//начало
Console.writeline('Vvedite X1 dlia tociki A: '); x1=Convert.toDouble(Console.readline());
Console.writeline('Vvedite Y1 dlia tociki A: '); y1=Convert.toDouble(Console.readline());

Console.writeline('Vvedite X2 dlia tociki B: '); x2=Convert.toDouble(Console.readline());
Console.writeline('Vvedite Y2 dlia tociki B: '); y2=Convert.toDouble(Console.readline());
Console.writeline('A(',x1:0:2,',',y1:0:2,') & '+'B(',x2:0:2,',',y2:0:2,')'); //это долго переделывать сам изменишь
da=false;
if ((x1>0) &&(y1>0) &&(x2<0) &&(y2>0)) {Console.writeline('peresekaet osi "OY"'); da=true;}
if ((x1>0) &&(y1>0) &&(x2<0) &&(y2<0)) {Console.writeline('peresekaet osi "XY"'); da=true;}
if ((x1>0) &&(y1>0) &&(x2>0) &&(y2<0)) {Console.writeline('peresekaet osi "OX"'); da=true;}
if( (x1<0) &&(y1>0) &&(x2<0) &&(y2<0)) {Console.writeline('peresekaet osi "OX"'); da=true;}
if ((x1<0) &&(y1>0) &&(x2>0) &&(y2<0)) {Console.writeline('peresekaet osi "XY"'); da=true;}
if ((x1<0) &&(y1<0) &&(x2>0) &&(y2<0)) {Console.writeline('peresekaet osi "OY"'); da=true;}

if ((x1<0) &&(y1>0) &&(x2>0) &&(y2>0)) then begin Console.writeline('peresekaet osi "OY"'); da=true;end;
if ((x1<0) &&(y1<0) &&(x2>0) &&(y2>0) )then begin Console.writeline('peresekaet osi "XY"'); da=true;end;
if ((x1>0) &&(y1<0) &&(x2>0) &&(y2>0)) then begin Console.writeline('peresekaet osi "OX"'); da=true;end;
if ((x1<0) &&(y1<0) &&(x2<0) &&(y2>0)) then begin Console.writeline('peresekaet osi "OX"'); da=true;end;
if ((x1>0) &&(y1<0) &&(x2<0) &&(y2>0)) then begin Console.writeline('peresekaet osi "XY"'); da=true;end;
if ((x1>0) &&(y1<0) &&(x2<0) &&(y2<0)) then begin Console.writeline('peresekaet osi "OY"'); da=true;end;

if(!da) Console.writeline('Eti tociki ne peresekaiyt ni odny osi');

Похожие вопросы
по си шарп, здесь в тексте ошибка?
что это я зделал? си шарп
подскажите по Си шарпу
Как изменить кодировку в Си шарп
Как программе удалить себя? Си шарп
Как написать программу Си Шарп?
перевод кода из паскаля на Си не найти ошибку.
Помогите переделать код с Python на Си++ код ниже.
в си шарп на глаз какие значение выведут два кода?
C#/C++ простой код библиотеки Си++ подключаю в Си шарп (внутри)