-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-2.c
More file actions
33 lines (31 loc) · 677 Bytes
/
10-2.c
File metadata and controls
33 lines (31 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
void increment_date(int *y,int *m,int *d){
//考虑不同月份,年份(闰年)
*d+=1;
if(*m==12&&*d==32){
*m=1;
*d=1;
*y+=1;
}else{
if((*m==1||*m==3||*m==5||*m==7||*m==8||*m==10)&&*d==32){
*m+=1;
*d=1;
}
else if((*m==4||*m==6||*m==9||*m==11)&&*d==31){
*m+=1;
*d=1;
}
}
if(*m==2){
if((*y%4==0&&*y%100!=0)||(*y%400==0)){
if(*d==30){
*m=3;
*d=1;
}
}else{
if(*d==29){
*m=3;
*d=1;
}
}
}