Simple calendar in C language,

Source: Internet
Author: User

Simple calendar in C language,

Simple calendar written in C language, the Code is as follows:

# Include <stdio. h> int main (int argc, const char * argv []) {// insert code here .. int year, month, day = 0, day1 = 0; printf ("Enter the year:"); scanf ("% d", & year ); printf ("Enter the month:"); scanf ("% d", & month ); printf ("one \ t Two \ t three \ t four \ t five \ t six \ t day \ n "); // determine whether the year is a leap year or this year for (int I = 1900; I <year; I ++) {if (I % 4 = 0 & I % 100! = 0) | I % 400 = 0) {day = day + 366;} else {day = day + 365 ;}} // determine the month for (int m = 1; m <= month; m ++) {switch (m) {case 4: case 6: case 9: case 11: day1 = 30; break; case 2: if (year % 4 = 0 & year % 100! = 0) | year % 400 = 0) {day1 = 29;} else {day1 = 28;} break; default: day1 = 31; break ;} if (m <month) {day = day + day1 ;}} int t; t = day % 7; // determine the day of the week on the first day of the month (int I = 0; I <t; I ++) {printf ("\ t ");} // control format: for (int I = 1; I <= day1; I ++) {printf ("% d \ t", I); if (I + day) % 7 = 0) {printf ("\ n") ;}} printf ("\ n"); return 0 ;}

 

The running effect is as follows:

Related Article

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.