一段用来判断日期是星期几的C代码
/////////////////////////////////////////////////
// 主题:一段用来判断日期是星期几的代码
// 描述:摘自《CCFAQ》
// 作者:天之枫
// 时间:2010-02-13
/////////////////////////////////////////////////
#include <stdio.h>
int dayofweek(int y, int m, int d) // 判断输入的日期是星期几
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
} /* 0 = Sunday */
int main(void)
{
printf( "今天是星期%d \n", dayofweek(2010,2,13) );
return 0;
}
相关文档:
1,栈区(stack)— 由编译器自动分配释放,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。 例如,声明在函数中的一个局部变量int b;系统自动在栈中为b开辟空间。只要栈的剩余空间大于所申请空间,系统将为程序提供内存,否则将报异常提示栈溢出。比如:
char* AllocStrfromStack ......
http://msdn.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx
#pragma
pack( n )
n : Valid values are 1, 2, 4, 8, and 16.the
alignment of a member will be on a boundary that is either a multiple of
n
or
a multiple of the size of the member
,
whichever is smaller.
......
1.2 单元测试的目标和方法
单元测试的目标是什么呢?就是完整检测代码单元的功能逻辑。找出代码单元本身的所有功能逻辑错误,具体来说,就是检测对数据的各种分类是否考虑全面,处理是否正确。单元测试并不是用来代替系统测试、性能测试的,它的目标相当明确,就是检测代码单元本身的功能逻辑错误。
& ......