In C + + programming, first output a row Sun Mon Tue Wed Thu Fri Fri, and then use the right alignment to print out the date, like the calendar
Output a row of sun Mon Tue Wed Thu Fri Fri, then remind the user to enter a start date and end date, and then output the results.
#include <iostream>#include<iomanip>//to set the field width, use the SETW function, so use the Iomanip header fileusing namespacestd;intMain () {intDay , Stop, I, J, Tian; cout<<"Enter the number of day and stop:"<<Endl; CIN>> Day >>stop; cout<<"Sun Mon Tue Wed Thu Fri Sat"<<Endl; for(j =0; J < Day; J + +)//processing spaces before the start datecout<< SETW (5) <<' '; for(i =1; I <= stop; i++)//Compare the I and stop date stops to determine when the output ends{Tian= (i + day)%7;//ensure that there are only seven elements in a row if(Tian = =0) cout<< SETW (5) << i << Endl;//up to seven elements for line break Elsecout<< SETW (5) <<i; } cout<<'\ n';//line wrapping at end of outputSystem ("Pause"); return 0;}
The output results are as follows:
In C + + programming, first output a row Sun Mon Tue Wed Thu Fri Fri, and then use the right alignment to print out the date, like the calendar