Программа определяет, какую из осей пересекает
отрезок, соединяющий две точки
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");
}
}
}
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");
}
}
}
я дурак, Ю мне делать нечего
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');
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');
Похожие вопросы
- С Си++ на си шарп
- Стоит ли изучать Си-шарп?
- я такой тупой что уже два года изучаю си шарп с перерывами и до сих пор не могу освоить основы, постоянно путаюсь в коде
- Си или Си шарп (С#)???
- Какой СИ. Какой СИ лучше? си плюс плюс или си шарп? что стоит учить в первую очередь?
- сильно ли си шарп отличается от си. а то очень охота си изучить, но там какита указатели и какита >
- Как думаете, глупо ли знать и джаву и си шарп? Или надо определить свой путь, и выбрать только одно из двух?
- Нужно написать программу на СИ++, которая переводит с паскаля на СИ++
- Программирование. Си шарп, си ++
- Помогите с одномерным массивом. Напишите код на Паскале.