判断闰年的C++程序

1#include <iostream>
 2using namespace std;
 3class ruinian{
 4       int y;
 5       bool ck(){
 6            bool a=false;
 7            if ((y%2==0 && y%100 !=0|| y%400 ==0)
 8               a=true;                    
 9            return a;           
10       }

11public:
12       int y_in(){
13         cin >> y;
14         return y;
15       }

16       int y_out(){
17         if (this->ck()){
18          cout << this-><< "年是闰年!" <<endl;
19          }
else{
20           cout << this-><< "年不是闰年!" <<endl;     
21          }
 
22          return 0;
23       }

24}
;
25
26int main()
27{
28    ruinian year;
29    cout << "请输入年份:" ; 
30    year.y_in ();   
31    year.y_out(); 
32}

33

posted on 2008-05-24 02:18 Keep-trying 阅读(707) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理


<2026年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿

文章档案(1)

最新随笔

搜索

最新评论