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

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.