当前位置:网站首页>[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;
}
边栏推荐
- How to restore the system with one click on Lenovo laptop
- [pyg] document summary and project experience (continuously updated
- 【Try to Hack】vulnhub DC4
- 模板引擎Velocity 基础
- 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"
- Free lottery | explore the future series of blind box digital copyright works of "abadou" will be launched on the whole network!
- Concatenate strings to get the result with the smallest dictionary order
- 游戏行业安全选择游戏盾,效果怎么样?
- Buuctf gold III
- Judge whether the binary tree is a binary search tree
猜你喜欢

ShenYu 网关开发:在本地启用运行

How to use F1 to F12 correctly on laptop keyboard

Soft test network engineer full truth simulation question (including answer and analysis)

數據庫系統原理與應用教程(006)—— 編譯安裝 MySQL5.7(Linux 環境)

Transition technology from IPv4 to IPv6

Rhcsa Road

机器学习11-聚类,孤立点判别

【C补充】【字符串】按日期排序显示一个月的日程

sql刷题627. 变更性别

How to use etcd to realize distributed /etc directory
随机推荐
Tutorial on principles and applications of database system (006) -- compiling and installing MySQL 5.7 (Linux Environment)
【C语言补充】判断明天是哪一天(明天的日期)
Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
How to use phpipam to manage IP addresses and subnets
Hi Fun Summer, play SQL planner with starrocks!
Please, stop painting star! This has nothing to do with patriotism!
mysql -- explain性能优化
Machine learning 11 clustering, outlier discrimination
C language input / output stream and file operation
Stegano in the world of attack and defense
How to repair the laptop that cannot connect to the wireless network
Concatenate strings to get the result with the smallest dictionary order
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
SystemVerilog structure (II)
阿里云、追一科技抢滩对话式AI
SQL question brushing 584 Looking for user references
独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作
Origin2018 installation and use (sorting)
Ring iron pronunciation, dynamic and noiseless, strong and brilliant, magic wave hifiair Bluetooth headset evaluation
P2592 [ZJOI2008]生日聚会(dp)