当前位置:网站首页>[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;
}
边栏推荐
- Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
- Girls who want to do software testing look here
- [kotlin] Introduction to higher-order functions
- Research and investment strategy report of neutral protease industry in China (2022 Edition)
- 为国产数据库添砖加瓦,StoneDB 一体化实时 HTAP 数据库正式开源!
- Tutorial on the principle and application of database system (001) -- MySQL installation and configuration: installation of MySQL software (Windows Environment)
- SQL question brushing 584 Looking for user references
- sql刷题584. 寻找用户推荐人
- How to repair the laptop that cannot connect to the wireless network
- How to optimize repeated if err in go language= Nil template code?
猜你喜欢

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"

Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)

String class

VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...

How to use etcd to realize distributed /etc directory

sql刷题1050. 合作过至少三次的演员和导演

巴比特 | 元宇宙每日必读:奈雪币、元宇宙乐园、虚拟股票游戏...奈雪的茶这波“操作拉满”的营销活动你看懂了吗?...

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

Endeavouros mobile hard disk installation

【C补充】【字符串】按日期排序显示一个月的日程
随机推荐
Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
sql刷题1050. 合作过至少三次的演员和导演
AI高考志愿填报:大厂神仙打架,考生付费围观
Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...
为国产数据库添砖加瓦,StoneDB 一体化实时 HTAP 数据库正式开源!
FPN network details
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
How to cancel automatic search and install device drivers for laptops
Activity的生命周期和启动模式详解
FRP intranet penetration, reverse proxy
Template engine velocity Foundation
Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
數據庫系統原理與應用教程(006)—— 編譯安裝 MySQL5.7(Linux 環境)
Is it reliable to open an account on flush with mobile phones? Is there any potential safety hazard
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
Research and investment strategy report of neutral protease industry in China (2022 Edition)
Transition technology from IPv4 to IPv6
P2893 [USACO08FEB] Making the Grade G(dp&优先队列)
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022