
Помогите пожалуйста определить високосный ли год или нет. Пишет YES или NO и следующий ближайший
високосный год. Это в паскале.

Ответы на вопрос

var a,i: integer;
begin
readln(a);
if (a mod 4 = 0) and (a mod 100<>0) or (a mod 400=0)
then writeln ('yes') else writeln ('no');
i:=a;
while true do
begin
i:=i+1;
if (i mod 4 = 0) and (i mod 100<>0) or (i mod 400=0) then
begin
writeln(i);
break;
end;
end;
end.



Determining Leap Year in Pascal
To determine if a year is a leap year in Pascal, you can use the `IsLeapYear` function. If the function returns true, the year is a leap year; otherwise, it's not.
Here's a simple example of how to use the `IsLeapYear` function in Pascal:
```pascal if IsLeapYear(Year) then ShowMessage('YES') else ShowMessage('NO'); ```
In the above code, `Year` is the variable representing the year you want to check.
Next Leap Year
To find the next leap year after a given year, you can simply iterate through the years and use the `IsLeapYear` function to check each year until you find the next leap year.
Here's a basic example of how you might do this in Pascal:
```pascal function FindNextLeapYear(CurrentYear: Integer): Integer; begin Inc(CurrentYear); // Start from the next year while not IsLeapYear(CurrentYear) do Inc(CurrentYear); Result := CurrentYear; end; ```
In the above code, `FindNextLeapYear` is a function that takes the current year as input and returns the next leap year.
Remember to replace `ShowMessage` with the appropriate method for displaying output in your specific Pascal environment.
I hope this helps! If you have any further questions or need additional assistance, feel free to ask.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili