小编use*_*026的帖子

如何比较C或C++中的日/月/年?

我有一个程序,要求用户输入日期然后它显示哪一个是最近我已经这样做了

if (year1>year2 || month1>month2 || day1>day2)
    return -1;

if (year1<year2 || month1<month2 || day1<day2)
    return +1;
Run Code Online (Sandbox Code Playgroud)

但输出不太正确.

c c++ comparison date

2
推荐指数
1
解决办法
1331
查看次数

标签 统计

c ×1

c++ ×1

comparison ×1

date ×1