论坛: 编程破解 标题: 大家看一下!!! 复制本贴地址    
作者: zhoen889 [zhoen889]    论坛用户   登录
#include<iostream.h>
class Time
{
private:
int year;
int month;
int day;
public:
Time(){};
Time(int y,int m,int d):year(y),month(m),day(d){};
int time();
};
int Time::time()
{
int days;
int leap;
int *p;
int day_tab[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,30},{0,31,29,31,30,31,30,31,31,30,31,30,30}};
leap=(year%4==0&&year%100!=0||year%400==0);
    days=day;
    for(p=day_tab[leap]+1;p<day_tab[leap]+month;p++)
    days=days+(*p);
return days;
}
void main()
{
int y1;
int m1;
int d1;
cout<<"Please input the year:";
cin>>y1;
cout<<"Please input the month:";
cin>>m1;
cout<<"Please input the day:";
cin>>d1;
Time *q;
q=new Time(y1,m1,d1);
cout<<"Today is:";
cout<<q->time()<<endl;
}


地主 发表时间: 11/28 20:16

回复: zhoen889 [zhoen889]   论坛用户   登录
大家怎么不回帖啊!!给我这个菜鸟一点鼓励吗。
哈哈。
多谢!!!

B1层 发表时间: 11/29 11:04

回复: lwei889 [lwei889]   论坛用户   登录
我想你应该算这样的天数,2000,1,1和2001,5,5相差多少天这样的!!


B2层 发表时间: 11/29 11:19

回复: zhoen889 [zhoen889]   论坛用户   登录
我可以用运算符重载!!


B3层 发表时间: 11/29 16:22

回复: hannyu [hannyu]   论坛用户   登录
鼓励一下
GOOD菜鸟!

B4层 发表时间: 11/29 16:36

回复: jiangweng [jiangweng]   论坛用户   登录
我也在学C~~但现在还看不懂。~!
  ~ 真向慕你。


B5层 发表时间: 11/30 14:14

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号