文章

34

粉丝

67

获赞

7

访问

8.7k

头像
偷菜时间表 题解:
P1053
发布于2024年2月24日 16:05
阅读数 228

/*
    思想:
    1、将每种菜的用时换算为分钟
    2、将提醒时间加到现在的时间上
    3、有可能要第二天了,所以小时数应该在24:00时变为0:00

*/

#include <bits/stdc++.h>

using namespace std;

int returnMinute(int hour, int minute) {
  int all = 0;
  for (int i = 0; i < hour; i++) {
    all += 60;
  }
  return all + minute;
}

void return_Hour_Minute(int minutes) {
  int hour = 0;  // 24小时是1440分钟
  if (minutes == 1440) { //正好是0:0时
    hour = 0;
    minutes -= 1440;
  }
  if (minutes > 1440) {
    minutes -= 1440;
    while (minutes >= 60) {
      hour++;
      minutes -= 60;
    }
  } else {
    while (minutes >= 60) {
      hour++;
      minutes -= 60;
    }
  }

  printf("%d:%d\n", hour, minutes);
}

int main() {
  int n;
...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发