微信公开课小程序热门讨论「求一个用C语言写的小程序」最新回复-不会写阴历,因为不懂,给你一个全年的不好意思,没看清楚你的问题,是自己以前写的,你要是自己调用系统时间的话,就自己编写吧,那个我不会。#includeiostream.h#includestdio.h#includestdlib.h#includeiomanip.h//处理年份boolIsLeapYear(intyear){return((year%400==0)||(year%100!=0&&year%4==0));}//处理天数intYearStartDay(intyear){return((year1)*365+(year1)/4)%7;}//处理月数intGetMonthDay(intyear,intmonth){intmonthcount[]={0,31,28,31,30,31,30,31,31,30,31,30,31};if(IsLeapYear(year))monthcount[2]++;returnmonthcount[month];}voidmain(){intyear,month,day,start,startday;cout请输入年份:;cinyear;coutendl;startday=YearStartDay(year);coutsetw(18)year的日历endl;coutendl;for(month=1;month=12;month++){coutsetw(18)month月endl;coutSUNsetw(6)MONsetw(6)TUEsetw(6)WENsetw(6)THUsetw(6)FRIsetw(6)SATendl;start=0;while(startstartday){start++;}coutsetw(start*6);for(day=1;day=GetMonthDay(year,month);day++){start++;startday++;if((start1)%7==0&&start!=1)coutendl;coutdaysetw(6);if(startday%7==0)startday=0;}coutendl;coutendl;}}
写一个循环 把前面每月的天数先加起来再加到这个月过的天数 注意判断下闰年就OK啦 更多有关「求一个用C语言写的小程序」的疑问请扫码关注微信公开课+小程序!了解更多