返回 课程

信奥AC之路-1级

0% 完成
0/0 步骤
  1. 第1课 开发环境与基础输出
    5 主题|小节
  2. 第2课 算术运算符
    7 主题|小节
  3. 第3课 printf与运算输出
    7 主题|小节
  4. 第4课 数的进制与拆位
    6 主题|小节
  5. 第5课 变量与基础运算
    17 主题|小节
  6. 第6课 常量与取整运算
    8 主题|小节
  7. 第7课 关系运算
    8 主题|小节
  8. 第8课 逻辑运算
    9 主题|小节
  9. 第9课 输入与计算进阶
    10 主题|小节
  10. 第10课 if语句及双分支语句
    8 主题|小节
  11. 第11课 if语句及双分支进阶
    11 主题|小节
  12. 第12课 三目运算
    9 主题|小节
  13. 第13课 多分支、多if和switch语句
    11 主题|小节
  14. 第14课 循环(基本输出)
    7 主题|小节
  15. 第15课 循环(While+If)
    8 主题|小节
  16. 第16课 循环(计数、求和、求乘积)
    10 主题|小节
  17. 第17课 循环进阶(While+)
    8 主题|小节
  18. 第18课 do-while及while其他用法
    8 主题|小节
  19. 第19课 For循环基础
    9 主题|小节
  20. 第20课 For循环进阶
    8 主题|小节
课 9, 主题|小节 6
进行中

9.5 综合实战

2025年9月22日
课 进展
0% 完成
// 综合运用时间计算和取整
int students, capacity, start_hour, start_minute;
scanf("%d%d%d:%d", &students, &capacity, &start_hour, &start_minute);

// 计算需要的批次(向上取整)
int batches = (students + capacity - 1) / capacity;

// 每批需要的时间(分钟)
int time_per_batch = 45;

// 计算总共需要的时间
int total_minutes = batches * time_per_batch;

// 计算结束时间
int start_in_minutes = start_hour * 60 + start_minute;
int end_in_minutes = (start_in_minutes + total_minutes) % (24 * 60);

// 转换为时分格式
int end_hour = end_in_minutes / 60;
int end_minute = end_in_minutes % 60;

printf("%d:%dn", end_hour, end_minute);