当前位置:网站首页>[Supplément linguistique c] déterminer quel jour est demain (date de demain)
[Supplément linguistique c] déterminer quel jour est demain (date de demain)
2022-07-01 16:54:00 【Un roseau pour voler FP】
Un.、Généralités
1.1 Description de la fonction
- Entrez au hasard une date valide,Date du jour suivant la sortie
1.2 Points saillants
- Si la date est le dernier jour du mois?
- Si c'est un février bissextile?
- Si c'est le dernier mois?
1.3 Méthode de réalisation
- Utilisation de structures,Stocke le mois, l'année et le jour dans une variable structurelle
2.、Code
#include<stdio.h>
#include<stdbool.h> //IntroductionboolType
struct date {
//Désignation de la structuredate
int year;
int month;
int day;
};
int numberOfDays(struct date d); //Jours d'un mois
bool isLeap(struct date d); //Année bissextile
int main(int argc, char* const argv[]){
struct date today, tommorow;
printf("Entrez la date(Année Mois Jour):");
scanf(" %i %i %i", &today.year, &today.month, &today.day);
if( today.day != numberOfDays(today) ){
//Comparer les jours, Pour déterminer si le dernier jour
tommorow.day = 1;
tommorow.month = today.month + 1;
tommorow.year = today.year;
}
else if( today.month == 12 ){
tommorow.day = 1;
tommorow.month =1;
tommorow.year = today.year + 1;
}
else {
tommorow.day = today.day + 1;
tommorow.month = today.month;
tommorow.year = today.year;
}
printf("Demain, oui. %iAnnée%iMois%iJour.\n",
tommorow.year, tommorow.month, tommorow.day);
return 0;
}
// Déterminer le nombre de jours de ce mois
int numberOfDays(struct date d)
{
int days; // Enregistrer les jours du mois
const int daysPerMonth[12] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // Nombre de jours par mois tout au long de l'année
if( d.month == 2 && isLeap(d) )
days = 29; // Février bissextile ,Prends - le.29Oh, mon Dieu.
else
days = daysPerMonth[d.month-1];
return days;
}
//Année bissextile
bool isLeap(struct date d)
{
bool leap = false;
//Année bissextile:Peut être4Diviser mais ne pas être100Effacer,Ou peut être400Effacer
if( (d.year%4 == 0 && d.year%100 != 0) || d.year%400 == 0 )
leap = true;
return leap;
}
边栏推荐
- China benzene hydrogenation Market Research and investment forecast report (2022 Edition)
- VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...
- Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
- Golang爬虫框架初探
- Babbitt | yuan universe daily must read: Naixue coin, Yuan universe paradise, virtual stock game Do you understand Naixue's tea's marketing campaign of "operation pull full"
- redis -- 数据类型及操作
- Zabbix2.2 monitoring system and application log monitoring alarm
- Determine whether the linked list is a palindrome linked list
- Basic usage of Frida
- Chinese diosgenin market forecast and investment strategy report (2022 Edition)
猜你喜欢

Transition technology from IPv4 to IPv6

Internet News: "20220222" get together to get licenses; Many products of Jimi have been affirmed by consumers; Starbucks was fined for using expired ingredients in two stores

Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!

Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...

Redis 分布式锁

Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers

免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!

Tutorial on the principle and application of database system (001) -- MySQL installation and configuration: installation of MySQL software (Windows Environment)

sql刷题584. 寻找用户推荐人

PR basic clip operation / video export operation
随机推荐
P2893 [USACO08FEB] Making the Grade G(dp&优先队列)
Tutorial on the principle and application of database system (003) -- MySQL installation and configuration: manually configure MySQL (Windows Environment)
Girls who want to do software testing look here
Is the securities account given by the head teacher of goucai school safe? Can I open an account?
FPN network details
Redis 分布式鎖
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Concatenate strings to get the result with the smallest dictionary order
Research and investment strategy report of hydroxypropyl beta cyclodextrin industry in China (2022 Edition)
数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
Are you still using charged document management tools? I have a better choice! Completely free
How to solve the keyboard key failure of notebook computer
Tutorial on the principle and application of database system (002) -- MySQL installation and configuration: MySQL software uninstallation (Windows Environment)
AI高考志愿填报:大厂神仙打架,考生付费围观
How to restore the system of Sony laptop
【C语言基础】12 字符串
判断链表是否是回文链表
How wild are hackers' ways of making money? CTF reverse entry Guide
数据库系统原理与应用教程(004)—— MySQL 安装与配置:重置 MySQL 登录密码(windows 环境)
【PyG】文档总结以及项目经验(持续更新