当前位置:网站首页>刷题-洛谷-P1085 不高兴的津津
刷题-洛谷-P1085 不高兴的津津
2022-07-25 13:32:00 【宋向上_UP】
P1085 不高兴的津津-C语言
1、题目

2、解题过程
(1)第一次 week[i] > week[i-1] 逻辑错误
结果:20
代码:
//洛谷 P1085 不高兴的津津
#include <stdio.h>
#define DAYS 7
int main() {
int week[DAYS];//每周时长
int u, v;//课内和课外时长
int i;
int max;//最长上课时长
int max_day;//最长上课时长的日期
for (i = 0; i < DAYS; i++) {
scanf_s("%d %d", &u, &v);
week[i] = u + v;//每日总时长
if (i == 0) {
max = week[i];
max_day = i;
}
else if (week[i] > week[i-1]) {
max = week[i];
max_day = i;
}
}
if (max > 8) {
printf("%d", max_day +1 );//不高兴程度最高
}
else {
printf("0");
}
return 0;
}
(2)第二次 week[i] > max
结果:
代码:
//洛谷 P1085 不高兴的津津
#include <stdio.h>
#define DAYS 7
int main() {
int week[DAYS];//每周时长
int u, v;//课内和课外时长
int i;
int max;//最长上课时长
int max_day;//最长上课时长的日期
for (i = 0; i < DAYS; i++) {
scanf("%d %d", &u, &v);
week[i] = u + v;//每日总时长
if (i == 0) {
max = week[i];
max_day = i;
}
else if (week[i] > max) {
max = week[i];
max_day = i;
}
//printf("第%d天学习的时长:%d。最大时长是%d,不高兴程度最高是%d", i + 1, week[i],max,max_day+1);
}
if (max > 8) {
printf("%d", max_day +1 );//不高兴程度最高
}
else {
//printf("\n 0");
printf("0");
}
return 0;
}
边栏推荐
- Mu Changchun, data Research Institute of the central bank: controllable anonymity of digital RMB is an objective need to safeguard public interests and financial security
- 二叉树基本知识
- Excel record macro
- 若依如何实现用户免密登录配置方法?
- Any time, any place, super detective, seriously handle the case!
- [six articles talk about scalablegnn] around www 2022 best paper PASCA
- 面试官问我:Mysql的存储引擎你了解多少?
- Hcip eighth day experiment
- The migration of arm architecture to alsa lib and alsa utils is smooth
- 【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)
猜你喜欢
![[ai4code final chapter] alphacode: competition level code generation with alphacode (deepmind)](/img/05/86eed30a7c063beace400a005e4a4c.png)
[ai4code final chapter] alphacode: competition level code generation with alphacode (deepmind)
![[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing](/img/6e/9e0abf8db5ec93080033bd89605ac2.jpg)
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing

QGIS loading online map: Gaode, Tiandi map, etc

ThreadLocal&Fork/Join

2022年下半年软考初级程序员备考

Excel record macro

Redis visualizer RDM installation package sharing

【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)

arm架构移植alsa-lib和alsa-utils一路畅通

VIM tip: always show line numbers
随机推荐
0713RHCSA
Date and time function of MySQL function summary
Basic knowledge of binary tree
Based on Baiwen imx6ull_ Pro development board transplants LCD multi touch driver (gt911)
ES6 array de duplication new set()
Canvas判断内容为空
【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)
Mu Changchun, data Research Institute of the central bank: controllable anonymity of digital RMB is an objective need to safeguard public interests and financial security
C # basic learning (XXIII)_ Forms and events
Leetcode 113. 路径总和 II
Docekr learning - MySQL 8 master-slave replication setup deployment
C#基础学习(二十三)_窗体与事件
The simplest solution of the whole network 1045 access denied for user [email protected] (using password:YES)
并发编程之AQS
【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
Leetcode 113. path sum II
Redis visualizer RDM installation package sharing
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
0719RHCSA