Вопрос задан 18.02.2019 в 00:23. Предмет Информатика. Спрашивает Кан Анастасия.

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

високосный год. Это в паскале.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Пономарёв Никита.
Program n1;
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.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос