编一个显示时间的程序,可以精确表示年、月、日、时、分、秒?
展开全部
#include<iostream>
using namespace std ;
typedef struct
{
int year ;
int month ;
int day;
int hour ;
int minute ;
int second ;
} Time ;
int main()
{
Time *time = new Time() ;
cout << "请输入年:" ;
cin >> time->year ;
cout << "请输入月:";
cin >> time->month ;
cout << "请输入日:";
cin >> time->day ;
cout << "请输入时:";
cin >> time->hour ;
cout << "请输入分钟:" ;
cin >> time->minute ;
cout << "请输入秒:" ;
cin >> time->second ;
//Display
cout << time->year << " 年 " << time->month << " 月 " << time->day << " 日 "
<< time->hour << " 时 " << time->minute << " 分 " << time->second << " 秒" << endl ;
return 0 ;
}
using namespace std ;
typedef struct
{
int year ;
int month ;
int day;
int hour ;
int minute ;
int second ;
} Time ;
int main()
{
Time *time = new Time() ;
cout << "请输入年:" ;
cin >> time->year ;
cout << "请输入月:";
cin >> time->month ;
cout << "请输入日:";
cin >> time->day ;
cout << "请输入时:";
cin >> time->hour ;
cout << "请输入分钟:" ;
cin >> time->minute ;
cout << "请输入秒:" ;
cin >> time->second ;
//Display
cout << time->year << " 年 " << time->month << " 月 " << time->day << " 日 "
<< time->hour << " 时 " << time->minute << " 分 " << time->second << " 秒" << endl ;
return 0 ;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询