C++实现的闰年判断程序

Posted on 2008-05-23 00:13 飞呀飞 阅读(1548) 评论(0)  编辑 收藏 引用 网摘 所属分类: C++
#include <iostream>
using namespace std;
class ruinian{
       
int y;
       
bool ck(){
            
bool a=false;
            
if ((y%2==0 && y%100 !=0|| y%400 ==0)
               a
=true;                    
            
return a;           
       }

public:
       
int y_in(){
         cin 
>> y;
         
return y;
       }

       
int y_out(){
         
if (this->ck()){
          cout 
<< this-><< "年是闰年!" <<endl;
          }
else{
           cout 
<< this-><< "年不是闰年!" <<endl;     
          }
 
          
return 0;
       }

}
;

int main()
{
    ruinian year;
    cout 
<< "请输入年份:" ; 
    year.y_in ();   
    year.y_out(); 
}


才开始学习C++编程,尝试着做了一下

只有注册用户登录后才能发表评论。
网站导航:

Copyright © 飞呀飞