描述:输入指定日期,输出输入日期的下一天的具体日期;
程序实现:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string ntime;
int tmp;
while(1)
{
cout<< "请输入日期,例如(0712-02-12)" << endl;
loop:
cin>>ntime;
while(ntime.length()!=10)
{
cout<<"您的输入有误,请重新输入日期,例如(0712-02-12)"<<endl;
goto loop;
}
while(ntime[4]!='-'||ntime[7]!='-')
{
cout<<"您的输入格式有误,请重新输入日期,例如(0712-02-12)"<<endl;
goto loop;
}
while(ntime[0]=='0'&&ntime[1]=='0'&&ntime[2]=='0'&&ntime[3]=='0')
{
cout<<"您的年份输入有误,请重新输入日期,例如(0712-02-12)"<<endl;
goto loop;
}
while(ntime[5]>='2'||(ntime[5]=='1'&&ntime[6]>='3'))
{
cout<<"您的月份输入有误,请重新输入日期,例如(0712-02-12)"<<endl

本文介绍了如何使用C++编程语言,结合STL库,实现一个nextday函数,该函数接收一个日期作为输入,并返回输入日期的次日。通过这个函数,开发者可以方便地进行日期操作。

6444

被折叠的 条评论
为什么被折叠?



