C++输入年月日,输出第二天是什么

输入年月日,输出第二天是什么
#include <iostream.h>
#include <string.h>
struct date
{
	int year,month,day;
};
int is_leap_year(struct date *pd){
	int flag=0;
	if ((pd->year%4==0&&pd->year%100!=0)||pd->year%400==0)
	{
		flag=1;
	}
	return flag;
}
int number_of_days(struct date *pd){
	int day=0;
	int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	if (is_leap_year(pd)&&pd->month==2)
	{
		day=29;
	}else{
		day=days[pd->month];
	}
	return day;
}


void main(){
	struct date today,tomorrow;
	cout<<"输入年月日(yyyy-mm-dd):"<<endl;
	cin>>today.year>>today.month>>today.day;
	if (today.day!=number_of_days(&today))
	{
		tomorrow.year=today.year;
		tomorrow.month=today.month;
		tomorrow.day=today.day+1;
	}
	else if (today.month==12)
	{
		tomorrow.year=today.year+1;
		tomorrow.month=1;
		tomorrow.day=1;
	}
	else{
		tomorrow.year=today.year;
		tomorrow.month=today.month+1;
		tomorrow.day=1;
	}
	cout<<tomorrow.year<<'-'<<tomorrow.month<<'-'<<tomorrow.day<<endl;
}


你可能感兴趣的:(C++,c,C#)