
На языке С или С++ . Напишите программу, которая получает день и номер месяца и определяет дату
сле-дующего дня. Считайте, что год невисокосный (365 дней). Пример: Введите день и месяц: 25 12 Следующий день: 26 декабря Пример: Введите день и месяц: 28 2 Следующий день: 1 марта

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

Program in C to Determine the Next Date
Here's a program written in C that takes the day and month as input and determines the date of the next day. It assumes a non-leap year with 365 days.
```c
#include
int main() { int day, month;
printf("Enter the day and month: "); scanf("%d %d", &day, &month);
// Determine the number of days in each month int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// Check if the entered day and month are valid if (month < 1 || month > 12 || day < 1 || day > daysInMonth[month - 1]) { printf("Invalid date!\n"); return 0; }
// Check if it's the last day of the month if (day == daysInMonth[month - 1]) { // Check if it's the last day of the year if (month == 12) { day = 1; month = 1; } else { day = 1; month++; } } else { day++; }
// Print the next date printf("Next day: %d ", day);
// Determine the month name based on the month number char* monthNames[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; printf("%s\n", monthNames[month - 1]);
return 0; } ```
This program prompts the user to enter the day and month. It then checks if the entered date is valid. If it is, it determines the next date by incrementing the day. If the day is the last day of the month, it checks if it's the last day of the year. If it is, it sets the day to 1 and increments the month. Finally, it prints the next date in the format "Next day: [day] [month name]".
Example: ``` Enter the day and month: 25 12 Next day: 26 December ```
``` Enter the day and month: 28 2 Next day: 1 March ```
Please note that this program assumes the input is valid and does not handle leap years.


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








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