C++程序 声明一个表示时间的结构体
声明一个表示时间的结构体,可以精确表示年、月、日、小时、分、秒;提示用户输入年、月、日、小时、分、秒的值,然后完整地显示出来。...
声明一个表示时间的结构体,可以精确表示年、月、日、小时、分、秒;提示用户输入年、月、日、小时、分、秒的值,然后完整地显示出来。
展开
展开全部
#include<iostream.h>
struct time
{ int year;
int month;
int day;
int hour;
int minute;
int seconds;
};
void main()
{ time one;
cout<<"Input your date(year): "; cin>>one.year;
cout<<"Input your date(month: )"; cin>>one.month;
cout<<"Input your date(day): "; cin>>one.day;
cout<<"Input your date(hour): "; cin>>one.hour;
cout<<"Input your date(minute): "; cin>>one.minute;
cout<<"Input your date(seconds): "; cin>>one.seconds;
cout<<"\n\nThis is your time: "<<one.year<<"-"<<one.month<<"-"<<one.day<<" "<<one.hour<<":"<<one.minute<<":"<<one.seconds;
}
struct time
{ int year;
int month;
int day;
int hour;
int minute;
int seconds;
};
void main()
{ time one;
cout<<"Input your date(year): "; cin>>one.year;
cout<<"Input your date(month: )"; cin>>one.month;
cout<<"Input your date(day): "; cin>>one.day;
cout<<"Input your date(hour): "; cin>>one.hour;
cout<<"Input your date(minute): "; cin>>one.minute;
cout<<"Input your date(seconds): "; cin>>one.seconds;
cout<<"\n\nThis is your time: "<<one.year<<"-"<<one.month<<"-"<<one.day<<" "<<one.hour<<":"<<one.minute<<":"<<one.seconds;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |