定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/10/03 12:27:00
定义一个时间类,能根据系统当前时间计算年龄.类中包含年月日.
#ifndef _DATE_TIME_H
#define _DTTE_TIME_H
#include
int get_year(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);\x09
return (l->tm_year + 1900);}
int get_month(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mon+1);}
int get_day(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mday);}
int get_hour(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_hour);}
int get_minuts(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_min);}
int get_seconds(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_sec);}
int get_week(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_wday);}
#endif 再答: 上面是用c写的,没有用类
再答: 类可以这么写。。。
再答: class Time{
int year(){
return get_year();}
int month(){
return get_month();}
int day(){
return get_day();}
};
省略掉。。。。。。了
再答: Time t;
int year=t.year();
这个是实例。。。哈哈
再问: 呵呵。年龄呢?系统时间?
再答: 啊。。。。
再答: 真贪婪。。。
再答: 写个函数得了
void age(int year){
Time t;
return t.year()-year;
}
#define _DTTE_TIME_H
#include
int get_year(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);\x09
return (l->tm_year + 1900);}
int get_month(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mon+1);}
int get_day(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_mday);}
int get_hour(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_hour);}
int get_minuts(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_min);}
int get_seconds(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_sec);}
int get_week(){
\x09time_t t;
\x09struct tm *l;\x09
\x09t = time(&t);
\x09l = localtime(&t);
return (l->tm_wday);}
#endif 再答: 上面是用c写的,没有用类
再答: 类可以这么写。。。
再答: class Time{
int year(){
return get_year();}
int month(){
return get_month();}
int day(){
return get_day();}
};
省略掉。。。。。。了
再答: Time t;
int year=t.year();
这个是实例。。。哈哈
再问: 呵呵。年龄呢?系统时间?
再答: 啊。。。。
再答: 真贪婪。。。
再答: 写个函数得了
void age(int year){
Time t;
return t.year()-year;
}
定义一个时间类Time满足:能设置时间;以“--:--:--”格式输出时分秒(display)
定义一个时间类TIME满足
C++ 如何从系统获取当前时间,要年月日,不要小时,分钟,秒的.
定义一个时间类Time,它能表示分,秒,时,并提供以下操作:
定义一个时间类Time,包含3个保护数据成员Hour(小时),Minute(分钟),second(秒)以及两个公有成员函
西门子s7-300编程,读取系统当前时间(年月日小时分秒),怎么判断这个时间在不在7点到10点之间?
在C#中怎样定义一个时间变量,并比较时间的大小?
java如何获取当前时间 年月日 时分秒
以当前时间计算年龄的代码:=datedif(A1,today(),"y")中A1在1900年后出生的人寿计算准确,此前出
1、定义一个时间Time,包含3个数据成员hour,minute,second,通过Set成员函数输入时间数据,通过di
谁能提供露点温度查询表,目的是要根据当前空气温度,直接在表中直接查询到露点温度,该表还包含相对湿度.
EXCEL中如何根据生日计算年龄?