c++以下程序定义了一个日期类,具有设置日期、判断闰年、输出日期等功能。程序对2000年8月23日进行测试。
#include"iostream.h"classTdate{private:intyear,month,day;public:voidsetdate(inty,intm...
#include "iostream.h"
class Tdate
{
private:
int year,month,day;
public:
void setdate(int y,int m,int d)
{
year=y; month=m; day=d;
}
int isleapyear()//该函数判断是否为闰年,若是闰年返回1,否则返回0
{
if(year%400==0||(year%4==0))
return 1;
else
return 0;
}
void print();
};
_______(2)______
{
cout<<year<<","<<month<<","<<day<<endl;
}
void main()
{
Tdate *date1;
______(3)______;
date1->setdate(2000,8,23);
date1->print();
if(______(4)______)
cout<<"leap year.\n";
else
cout<<"leap year.\n";
}
麻烦厉害的人帮忙看看! 展开
class Tdate
{
private:
int year,month,day;
public:
void setdate(int y,int m,int d)
{
year=y; month=m; day=d;
}
int isleapyear()//该函数判断是否为闰年,若是闰年返回1,否则返回0
{
if(year%400==0||(year%4==0))
return 1;
else
return 0;
}
void print();
};
_______(2)______
{
cout<<year<<","<<month<<","<<day<<endl;
}
void main()
{
Tdate *date1;
______(3)______;
date1->setdate(2000,8,23);
date1->print();
if(______(4)______)
cout<<"leap year.\n";
else
cout<<"leap year.\n";
}
麻烦厉害的人帮忙看看! 展开
展开全部
#include "iostream.h"
class Tdate
{
private:
int year,month,day;
public:
void setdate(int y,int m,int d)
{
year=y; month=m; day=d;
}
int isleapyear()//该函数判断是否为闰年,若是闰年返回1,否则返回0
{
if(year%400==0||(year%4==0)) //我认为应该是if(year%400==0||(year%4==0&&year%100!=0))
return 1;
else
return 0;
}
void print();
};
void Tdate::print()//_______(2)______
{
cout<<year<<","<<month<<","<<day<<endl;
}
void main()
{
Tdate *date1;
date1=new Tdate;//______(3)______;
date1->setdate(2000,8,23);
date1->print();
if(date1->isleapyear())//______(4)______)
cout<<"leap year.\n";
else
cout<<"leap year.\n";
}
class Tdate
{
private:
int year,month,day;
public:
void setdate(int y,int m,int d)
{
year=y; month=m; day=d;
}
int isleapyear()//该函数判断是否为闰年,若是闰年返回1,否则返回0
{
if(year%400==0||(year%4==0)) //我认为应该是if(year%400==0||(year%4==0&&year%100!=0))
return 1;
else
return 0;
}
void print();
};
void Tdate::print()//_______(2)______
{
cout<<year<<","<<month<<","<<day<<endl;
}
void main()
{
Tdate *date1;
date1=new Tdate;//______(3)______;
date1->setdate(2000,8,23);
date1->print();
if(date1->isleapyear())//______(4)______)
cout<<"leap year.\n";
else
cout<<"leap year.\n";
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.if(year%400==0||(year%4==0)&&(year%100!=0))// 你忘记标了这里,如果这里不标是错误。
2.void Tdate::print()
3.date1=new Tdate;
4.if(date1->isleapyear());
2.void Tdate::print()
3.date1=new Tdate;
4.if(date1->isleapyear());
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询