4 回答
TA贡献2016条经验 获得超9个赞
#include <stdio.h>
#include <time.h>
int main()
{
unsigned int hour,minu;
///////////////////////////////输入部分
int key=0;
printf("input a time:\t");
do
{
key=scanf("%u:%u",&hour,&minu);
if (hour>24 || minu>60)
{
printf("input error!\n");
fflush(stdin);
printf("input a time:\t");
key=0;
}
}
while(key!=2);
/////////////////////////////比较部分
{
time_t systime;
struct tm * timeinfo;
time(&systime);
timeinfo = localtime( &systime );
printf("your input is:%d:%d\n",hour,minu);
printf("system time is:%d %d\n",timeinfo->tm_hour,timeinfo->tm_min);
if (hour>timeinfo->tm_hour)
{
printf("your inpur is bigger!\n");
return 1;
}
if (hour==timeinfo->tm_hour)
{
if (minu>timeinfo->tm_min)
{
printf("your inpur is bigger!\n");
return 1;
}
if (minu==timeinfo->tm_min)
{
printf("euqual!!\n");
return 1;
}
else
{
printf("system time is bigger!\n");
return 1;
}
}
printf("system time is bigger!\n");
return 1;
}
}
- 4 回答
- 0 关注
- 1701 浏览
添加回答
举报