声明一个表示时间的结构体,可以精确表示年、月、日、小时、分、秒;提示用户输入,然后完整地显示出来
1个回答
展开全部
#include <stdio.h>
typedef struct
{
int rtc_sec;
int rtc_min;
int rtc_hour;
int rtc_day;
int rtc_mon;
int rtc_year;
}rtc_time;
void main()
{
rtc_time time={0};
printf("Input Year:\n");
scanf("%d",&time.rtc_year);
printf("Input Mounth:\n");
scanf("%d",&time.rtc_mon);
printf("Input Day:\n");
scanf("%d",&time.rtc_day);
printf("Input Hour:\n");
scanf("%d",&time.rtc_hour);
printf("Input Minite:\n");
scanf("%d",&time.rtc_min);
printf("Input Senconds:\n");
scanf("%d",&time.rtc_sec);
printf("\nInput Time:%d-%d-%d %02d:%02d:%02d\n",
time.rtc_year,time.rtc_mon,time.rtc_day,
time.rtc_hour,time.rtc_min,time.rtc_sec);
}
typedef struct
{
int rtc_sec;
int rtc_min;
int rtc_hour;
int rtc_day;
int rtc_mon;
int rtc_year;
}rtc_time;
void main()
{
rtc_time time={0};
printf("Input Year:\n");
scanf("%d",&time.rtc_year);
printf("Input Mounth:\n");
scanf("%d",&time.rtc_mon);
printf("Input Day:\n");
scanf("%d",&time.rtc_day);
printf("Input Hour:\n");
scanf("%d",&time.rtc_hour);
printf("Input Minite:\n");
scanf("%d",&time.rtc_min);
printf("Input Senconds:\n");
scanf("%d",&time.rtc_sec);
printf("\nInput Time:%d-%d-%d %02d:%02d:%02d\n",
time.rtc_year,time.rtc_mon,time.rtc_day,
time.rtc_hour,time.rtc_min,time.rtc_sec);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询