当前位置:网站首页>[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;
}
边栏推荐
- Girls who want to do software testing look here
- Detailed explanation of activity life cycle and startup mode
- 嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
- 数据库系统原理与应用教程(003)—— MySQL 安装与配置:手工配置 MySQL(windows 环境)
- 数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
- Redis Distributed Lock
- 数据库系统原理与应用教程(002)—— MySQL 安装与配置:MySQL 软件的卸载(windows 环境)
- How to use phpipam to manage IP addresses and subnets
- 如何使用 etcd 实现分布式 /etc 目录
- Endeavouros mobile hard disk installation
猜你喜欢
C语言输入/输出流和文件操作
机器学习11-聚类,孤立点判别
How to use F1 to F12 correctly on laptop keyboard
Redis distributed lock
Rhcsa Road
Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid
Authentication processing in interface testing framework
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
你还在用收费的文档管理工具?我这有更牛逼的选择!完全免费
What is the effect of choosing game shield safely in the game industry?
随机推荐
剑指 Offer II 105. 岛屿的最大面积
How to optimize repeated if err in go language= Nil template code?
Redis6.0 new features
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
How to cancel automatic search and install device drivers for laptops
VMware 虚拟机启动时出现故障:VMware Workstation 与 Hyper-v 不兼容...
Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
Dataframe gets the number of words in the string
mysql -- explain性能优化
Sword finger offer II 015 All modifiers in the string
Tutorial on principles and applications of database system (004) -- MySQL installation and configuration: resetting MySQL login password (Windows Environment)
Computed property “xxx“ was assigned to but it has no setter.
Virtual serial port simulator and serial port debugging assistant tutorial "suggestions collection"
Machine learning 11 clustering, outlier discrimination
Go language source level debugger delve
【Try to Hack】vulnhub DC4
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
游戏行业安全选择游戏盾,效果怎么样?
[flask introduction series] cookies and session