Solve the problem, first ask each month is the day of the week, then the next operation, you can one step
1#include <iostream>2 using namespacestd;3 //********** Festival Calculation *************4 //calculate y1 The first day of a month is the days of the week5 intmonth[ A]={ to, -, to, -, to, -, to, to, -, to, -, to};6 intDayintY1,inta) {7 inty3=0;8 intc1=2;9 for(intYear=1850; year<y1;year++){Ten intD=365; month[1]= -; One if((year%4==0&&year% -!=0)|| year% -==0){ AD=366; month[1]= in; - } -y3+=D; the } - for(intI=0; i<a-1; i++){ -y3+=Month[i]; - } +c1+=y3%7; - if(c1==8){ +c1=1; A } at returnC1; - } - intMain () { - //Holiday Calculation - inta,b,c,y1,y2,c2; -Cin>>a>>b>>c>>y1>>Y2; in for(inty=y1;y<=y2;y++){ -month[1]= -; to if((y%4==0&&y% -!=0)|| y% -==0){ +month[1]= in; - } the if(c>Day (Y,a)) { *C2=c-day (y,a) +7* (b-1)+1; $ }Panax Notoginseng Else{ -C2=c-day (y,a) +7*b+1; the } + if(c2>month[a-1]){ Acout<<"None"<<Endl; the } + Else{ -cout<<y; $ if(a<Ten){ $cout<<"/0"<<A; - } - Else{ thecout<<"/"<<A; - }Wuyi if(c2<Ten){ thecout<<"/0"<<c2<<Endl; - } Wu Else{ -cout<<"/"<<c2<<Endl; About } $ } - } - - return 0; A +}
Date calculation----month x Week x (CCF question)//c++