ywtl.net
当前位置:首页>>关于C语言程序,输入年月日算出当天星期几的资料>>

C语言程序,输入年月日算出当天星期几

#include "stdio.h" void CaculateWeekDay(int y,int m, int d) { if(m==1||m==2) { m+=12; y--; } int iWeek=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; switch(iWeek) { case 0: printf("星期一 "); break; case 1: printf("星期二 "); break; c...

不必用 switch. 以前编过一个. 现在找出来配了个主程序. 你试试吧. ---输入年,月,日:2000,3,1 答: 2000年3月1日是星期三. ---输入年,月,日:2008,4,20 答: 2008年4月20日是星期日. ---输入年,月,日:0 年月日数字用逗号隔开. 想结束的时候输入一个...

#includeint main(){int y, m, d, w;scanf("%d %d %d", &y,&m,&d);if(3 > m){m+= 12;y--;}w=((d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7+1)%7;printf("%d",w);return 0;}

#include int main() { int day,mn,yr,i,days=0,s,k; int mont[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; char wek[][9]={ {'S','u','n','d','a','y'}, {'M','o','n','d','a','y'}, {'T','u','e','s','d','a','y'}, {'W','e','d','n','s','...

我觉得这样写可能好点 #include #include #define DYTS 31 //大月天数 #define XYTS 30 //小月天数 #define RYTS 29 //闰月天数(2008年是一闰年) #define YZTS 7 //一周天数 int main(void) { int yue,ri; //日,月 int tian = 0 ; //存储某月某...

简单,用蔡勒公式即可: #include int main () { int y, m, d, c, w; printf ("输入年 月 日(空格间隔):"); scanf ("%d %d %d", &y, &m, &d); if (m ==1 || m == 2) { //判断月份是否为1或2 y--; m += 12; } c = y / 100; y = y - c * 100; w...

#include #define SIZE 31 void inputCheck(int,int,int); int leaYear(int); main() { int year,month,day,d1,result,sum=0; scanf("%d%d%d",&year,&month,&day); inputCheck(year,month,day); for(;year>1; year--) { if((year%4==0 && year%1...

#include "stdio.h" int main(void) { int a,b,year,month,day,count=0; int mon[12]={0,31,28,31,30,31,30,31,31,30,31,30}; printf("Please input year month day like this xxxx,xx,xx\n"); scanf("%d,%d,%d",&year,&month,&day); for(a=1900;a

请分别输入年月日三个数值,计算出这是这一年的第几天?(提示:要考虑闰年和2月的情况)*/#include void main(){int year=0,month=0,day=0,i=0,sum=0;while(1){printf("请输入年份:"); scanf("%d",&year); printf("请输入月份:"); scanf("%d"...

#include main() { int year,year1,month,month1,day,day1,age; printf("请输入您的生日:"); scanf("%d %d %d",&year,&month,&day); printf("请输入当前日期:"); scanf("%d %d %d",&year1,&month1,&day1); if(year1==year) age=0; else {age=yea...

网站首页 | 网站地图
All rights reserved Powered by www.ywtl.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com