import java.util.Scanner;
class Main {
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
System.out.println ("Let's play the lottery!");
System.out.println ("Enter an integer from 0 to 100");
boolean won = false;
int x = 0;
x = input.nextInt ();
if (x > 100)
{
System.out.println ("You entered a number outside the specified limits!");
System.out.println ("Enter a new number");
x = input.nextInt ();
}
if (x < 0)
{
System.out.println ("You entered a number outside the specified limits!");
System.out.println ("Enter a new number");
x = input.nextInt ();
}
if (x == 10)
{
System.out.println ("You are lucky. You won 100$");
won = true;
}
if (x == 50)
{
System.out.println ("Luck is always with you. You won 10$");
won = true;
}
if (x == 99)
{
System.out.println ("Good job. You won 50$");
won = true;
}
if (x == 1)
{
System.out.println ("The winning is 20$");
won = true;
}
if (!won)
{
System.out.println("You are not lucky. Try next time");
}
System.out.println ("End!");
}
}
Объяснение:
PROGRAM Privet;
VAR
x:real;
BEGIN
writeln('Который час?'); read(x);
if x > 24 then
writeln('Введенное число не является временем ' )
else
begin
if (x>=8) and (x<12) then writeln('Доброе утро!');
if (x>=12) and (x<17) then writeln('Добрый день!');
if(x>=17) and (x<23) then writeln('Добрый вечер!');
if(x>=23) or (x<8) then writeln('Доброй ночи!');
end;
end.
//вторая программа
var
x,x1,x2,y,y1,y2:real;
begin
write('x = '); readln(x);
write('y = '); readln(y);
write('x1 = '); readln(x1);
write('y1 = '); readln(y1);
write('x2 = '); readln(x2);
write('y2 = '); readln(y2);
if ((x - x1) * (x - x2) < 0) and ((y - y1) * (y - y2) < 0) then
writeln('Точка принадлежит заданной области')
else
writeln('Точка не принадлежит заданной области');
end.