Даны целые числа x и y. написать программу определения знака разности x-y. разность вычислять нельзя. разрешается сравнивать числа x и y с нулем, а между собой можно сравнивать только абсолютные величины чисел x и y.
Program raznost_xy; var x, y:integer; begin write ('Введите число х = '); readln (x); write ('Введите число у = '); readln (y);
if (x>0) and (y>0) then begin if abs(x)>abs(y) then write ('x-y > 0'); if abs(x)=abs(y) then write ('x-y = 0'); if abs(x)<abs(y) then write ('x-y < 0'); end;
if (x<0) and (y<0) then begin if abs(x)>abs(y) then write ('x-y < 0'); if abs(x)=abs(y) then write ('x-y = 0'); if abs(x)<abs(y) then write ('x-y > 0'); end;
if (x=0) and (y=0) then write ('x-y = 0'); if (x>0) and (y<0) then write ('x-y > 0'); if (x<0) and (y>0) then write ('x-y < 0'); if (x=0) and (y>0) then write ('x-y < 0'); if (x=0) and (y<0) then write ('x-y > 0'); if (x>0) and (y=0) then write ('x-y > 0'); if (x<0) and (y=0) then write ('x-y < 0'); end.
// PascalABC.NET 3.1, сборка 1230 от 27.04.2016 begin var s:=ReadLines('in.txt').ToArray; var n:=StrToInt(s[0]); var a:=s[1].ToWords.Select(e->StrToInt(e)).ToArray; var f:=OpenWrite('out.txt'); Writeln(f,n,' - (кол-во чисел)'); foreach var e in a do Write(f,e,' '); Writeln(f); Writeln(f,'Среднее значение четных ', a.Where(x->x.IsEven).Average); Writeln(f,'Среднее значение нечетных ', a.Where(x->x.IsOdd).Average); f.Close end.
Возможный вариант в C++ #include <iostream> int main() { using namespace std; int N; cout << "Enter N: "; cin >> N; int num; int max = 1; int i; for (i = 0; i < N; ++i) { cout << "Enter #" << i + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) { max = num; break; } } for (int j = i + 1; j < N; ++j) { cout << "Enter #" << j + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) if (num > max) max = num; } if (max != 1) cout << "Max number div by 3 and don't end 9: " << max << endl; else cout << "No numbers div by 3 and don't end 9" << endl; return 0; }
var x, y:integer;
begin
write ('Введите число х = ');
readln (x);
write ('Введите число у = ');
readln (y);
if (x>0) and (y>0) then
begin
if abs(x)>abs(y) then write ('x-y > 0');
if abs(x)=abs(y) then write ('x-y = 0');
if abs(x)<abs(y) then write ('x-y < 0');
end;
if (x<0) and (y<0) then
begin
if abs(x)>abs(y) then write ('x-y < 0');
if abs(x)=abs(y) then write ('x-y = 0');
if abs(x)<abs(y) then write ('x-y > 0');
end;
if (x=0) and (y=0) then write ('x-y = 0');
if (x>0) and (y<0) then write ('x-y > 0');
if (x<0) and (y>0) then write ('x-y < 0');
if (x=0) and (y>0) then write ('x-y < 0');
if (x=0) and (y<0) then write ('x-y > 0');
if (x>0) and (y=0) then write ('x-y > 0');
if (x<0) and (y=0) then write ('x-y < 0');
end.