给定年,月,日,计算该日是该年中的第几天。程序中要求有判断闰年的函数和计算天数的函数。

[复制链接]
查看11 | 回复0 | 2010-11-23 14:18:42 | 显示全部楼层 |阅读模式
#include #include using namespace std;bool IsRunYear( const int year ){assert(year > 0);if ( (year%4==0&&year%100!=0) || (year%400==0) )return true;else return false;}int main(){int total = 0;for(int year = 2000; year <= 2500; ++year){if(IsRunYear(year)){cout<<year<<" ";total++;if(total%15==0){cout<<endl;}}}cout<<endl;cout<<"total is "<<total<<endl;return 0;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行