您好,欢迎访问三七文档
当前位置:首页 > 财经/贸易 > 资产评估/会计 > NextDate C++ 代码
一、调试后的代码1.#includeiostream2.usingnamespacestd;3.inta,b,c,y,m,d;4.//判断是否为闰年5.boolFeb(inty){6.if((2060-y)%4==0)7.return1;8.else9.return0;}10.//年份的累加11.intNextYear(inty){12.a=y+1;13.if(a2060)14.{coutNextdateisoutoftherecord./n;15.return1;}16.else17.returna;}18.//月份的累加19.intNextMonth(intm){20.b=m+1;21.if(b==13){22.b=1;23.NextYear(y);}24.returnb;}25.//天数的累加26.intNextDay(intd){27.c=d+1;28.//大月满32天月份加129.if(c==32){30.if(m==1|m==3|m==5|m==7|m==8|m==10|m==12)31.{c=1;32.NextMonth(m);}}33.//小月满31天月份加134.if(c==31){35.if(m==4|m==6|m==9|m==11)36.{c=1;37.NextMonth(m);}}38.//若为闰年,2月满30天,月份加139.if(c==30){40.if(Feb(y)&&m==2){41.c=1;42.b=3;}}43.//若不是闰年,2月满29天,月份加144.if(c==29){45.if(!Feb(y)&&m==2){46.c=1;47.b=3;}}48.returnc;}49.//NextDate函数50.intNextDate(inty,intm,intd){51.if(y1900|y2060|m1|m12|d1|d31){52.coutThisdateisoutoftherecord,pleaseinputtherightdate.\n;53.return1;}54.if(m==4|m==6|m==9|m==11&&d==31){55.coutThisdateisoutoftherecord,pleaseinputtherightdate.\n;56.return1;}57.if(Feb(y)&&m==2&&d29){58.coutThisdateisoutoftherecord,pleaseinputtherightdate.\n;59.return1;}60.if(!Feb(y)&&m==2&&d28)61.{coutThisdateisoutoftherecord,pleaseinputtherightdate.\n;62.return1;}63.else{64.NextDay(d);65.coutNextdateisa.b.c\n\n;66.return0;}}67.//main函数68.intmain()69.{while(1){70.coutPleaseinputthecurrentdate.\n;71.coutThedomainisfrom1900to2060\n;72.coutYEAR\n;73.ciny;74.coutMONTH\n;75.cinm;76.coutDAY\n;77.cind;78.a=y;79.b=m;80.c=d;81.NextDate(y,m,d);}82.return0;}
本文标题:NextDate C++ 代码
链接地址:https://www.777doc.com/doc-5957736 .html