tianxuyuan

放假在家 学习类 今天编了日期简单处理的

//===========================
#include<iostream>
#include<iomanip>
//========================
using namespace std;
class Date{
 int year,month,day;
public:
 bool isleapyear(){
   return(year%4==0&&year%100!=0)||(year%400==0);
   }
 void print(){
  cout<<setfill('0');
  cout<<setw(4)<<year<<'-'<<setw(2)<<month<<'-'<<setw(2)<<day<<'\n';
  cout<<setfill(' ');
  }
  void set(int y,int m,int d){
   year=y;  month=m; day=d;
  }
 };
//--------------------------
int main(){
 Date kk;
 int n;cin>>n;
 for(int i=1;i<=n;i++){
    int y;int m;int d;
     cin>>y>>m>>d;                                   //  kk.set(1000,8,16);
     kk.set(y,m,d);
    if(kk.isleapyear()) kk.print();
     else cout<<"notleap\n";
  }
 cout<<"over"<<'\n';
}
//--------------------------

想用类做8个排序算法 有点没有头绪阿

posted on 2007-08-16 11:15 田旭园 阅读(305) 评论(1)  编辑 收藏 引用

Feedback

# re: 放假在家 学习类 今天编了日期简单处理的 [未登录] 2007-08-16 18:55 ic

应该有个算算两个日期之间的天数间隔的函数的。  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理