作业帮 > 综合 > 作业

c++中如何声明一个时间的结构体,可以精确表示年,月,日,时,分,秒.提示用户输入时间,并完整表示出来

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 03:32:54
c++中如何声明一个时间的结构体,可以精确表示年,月,日,时,分,秒.提示用户输入时间,并完整表示出来
VC编译运行通过
#include
#include
void main()
{
\x09struct time{
\x09\x09int year;
\x09\x09int mouth; //声明一个结构体,它的成员依次是年月日时分秒
\x09\x09int day;
\x09\x09int minuter;
\x09\x09int second;
\x09};
\x09time pt;
\x09printf("input the current time\n");
\x09scanf("%d%d%d%d%d",&pt.year,&pt.mouth,&pt.day,&pt.minuter,&pt.second);
\x09printf("the time is %d%d%d%d%d\n",pt.year,pt.mouth,pt.day,pt.minuter,pt.second);
}