1:
#define START_YEAR 1950
#define END_YEAR 2050
int IsLeapYear(WORD iYear)
{return !(iYear%4)&&(iYear%100) || !(iYear%400);}
LONG CalcDateDiff(WORD iEndYear, WORD iEndMonth, WORD iEndDay,
WORD iStartYear, WORD iStartMonth, WORD iStartDay)
{
WORD monthday[]={0, 31, 59 ,90, 120, 151, 181, 212, 243, 273, 304, 334};
//计算两个年份1月1日之间相差的天数
LONG iDiffDays =(iEndYear - iStartYear)*365;
iDiffDays += (iEndYear-1)/4 - (iStartYear-1)/4;
iDiffDays -= ((iEndYear-1)/100 - (iStartYear-1)/100);
iDiffDays += (iEndYear-1)/400 - (iStartYear-1)/400;
//加上iEndYear年1月1日到iEndMonth月iEndDay日之间的天数
iDiffDays += monthday[iEndMonth-1] +
(IsLeapYear(iEndYear)&&iEndMonth>2? 1: 0);
iDiffDays += iEndDay;
//减去iStartYear年1月1日到iStartMonth月iStartDay日之间的天数
iDiffDays -= (monthday[iStartMonth-1] +
(IsLeapYear(iStartYear)&&iStartMonth>2 ? 1: 0));
iDiffDays -= iStartDay;
return iDiffDays;
}
上面的宏定义可以改成需要的,这是用C++写的,你可以将WORD改成unsigned int,没有什么区别的!
由于时间有限,先回答这一点了。
最后一个的解
#include \"Stdio.h\"
#include \"Conio.h\"
int main(void)
{ int a[15],i,j,n,mid;
for (i=0;i<15;i++)
{ a[i]=i*2;
printf(\"a[%d]=%d\\n\",i,i*2);}
printf(\"please input n=\");
scanf(\"%d\",&n);
mid=(a[0]+a[14])/2 ;
while(mid!=n)
{ if (mid>n) mid=(mid+a[0])/2;
if (mid
printf(\"find!! %d is right\",mid);
}