Chinaunix首页 | 论坛 | 博客
  • 博客访问: 163546
  • 博文数量: 13
  • 博客积分: 3084
  • 博客等级: 中校
  • 技术积分: 259
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-15 11:57
文章分类

全部博文(13)

文章存档

2015年(2)

2014年(1)

2013年(7)

2012年(3)

我的朋友

分类: C/C++

2012-03-27 10:07:00

#include int get_Weekday(int Year,int Month,int Day) { int Weekday=0, Century=0; if (1 == Month ) { Month = 13; Year = Year -1; } else if (2 == Month ) { Month = 14; Year = Year -1; } Century = (Year/100); Year = Year%100; Weekday = (Century/4) - (2*Century) + Year + (Year/4) + (13 * (Month+1) / 5) + Day - 1; Weekday = Weekday%7; if (Weekday < 0) { Weekday += 7; } return Weekday; } int main(int argc, char * argv[]) { int year,month,weekofmonth,dayofweek,weekday; int sumday = 0; int leap = 0; if (argc != 5) { printf("invalid pararm! year month nweek weekdays\n"); return 1; } year = atoi(argv[1]); month = atoi(argv[2]); weekofmonth = atoi(argv[3]); dayofweek = atoi(argv[4]); printf("year %d month %d weekofmonth %d weekdays %d\n", year, month, weekofmonth, dayofweek); weekday = get_Weekday(year, month, 1); printf("weekday %d\n", weekday); if (0 == weekday) { sumday = (weekofmonth - 1) * 7 + dayofweek; } else { sumday = 7 - weekday + ( weekofmonth - 1) * 7 + dayofweek; } printf("%d/%d/%d\n", year, month, sumday); return 0; }
阅读(1175) | 评论(1) | 转发(0) |
0

上一篇:没有了

下一篇:SQL case when用法

给主人留下些什么吧!~~

认真的鱼1232012-03-27 22:37:16

哦,这个是根据计时器和出师时间来算吧~