当前位置:网站首页>Brush questions - Luogu -p1085 unhappy Jinjin
Brush questions - Luogu -p1085 unhappy Jinjin
2022-07-25 13:47:00 【Song Xiangshang_ UP】
P1085 Unhappy Jinjin -C Language
1、 subject

2、 The problem solving process
(1) for the first time week[i] > week[i-1] Logic error
result :20
Code :
// Luogu P1085 Unhappy Jinjin
#include <stdio.h>
#define DAYS 7
int main() {
int week[DAYS];// Weekly duration
int u, v;// In class and out of class hours
int i;
int max;// The longest class time
int max_day;// The date of the longest class
for (i = 0; i < DAYS; i++) {
scanf_s("%d %d", &u, &v);
week[i] = u + v;// Total time per day
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 );// The degree of unhappiness is the highest
}
else {
printf("0");
}
return 0;
}
(2) The second time week[i] > max
result :
Code :
// Luogu P1085 Unhappy Jinjin
#include <stdio.h>
#define DAYS 7
int main() {
int week[DAYS];// Weekly duration
int u, v;// In class and out of class hours
int i;
int max;// The longest class time
int max_day;// The date of the longest class
for (i = 0; i < DAYS; i++) {
scanf("%d %d", &u, &v);
week[i] = u + v;// Total time per day
if (i == 0) {
max = week[i];
max_day = i;
}
else if (week[i] > max) {
max = week[i];
max_day = i;
}
//printf(" The first %d Days of study :%d. The maximum duration is %d, The highest degree of unhappiness is %d", i + 1, week[i],max,max_day+1);
}
if (max > 8) {
printf("%d", max_day +1 );// The degree of unhappiness is the highest
}
else {
//printf("\n 0");
printf("0");
}
return 0;
}
边栏推荐
- Leetcode1 -- sum of two numbers
- 【力扣】645.错误的集合
- Azure Devops (XIV) use azure's private nuget warehouse
- Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
- QGIS loading online map: Gaode, Tiandi map, etc
- @Wrap decorator
- 说说对hashcode和equals方法的理解?
- Concurrent tool set for concurrent programming
- What is your revenue rank among global developers in 2022?
- 音视频技术开发周刊 | 255
猜你喜欢

How to refactor embedded code?

刷题-洛谷-P1152 欢乐的跳

0710RHCSA

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

Preparing for the soft test for junior programmers in the second half of 2022

ES6 array de duplication new set()

"Digital security" alert NFT's seven Scams

Applet enterprise red envelope function

JS array indexof includes sort() colon sort quick sort de duplication and random sample random

QGIS loading online map: Gaode, Tiandi map, etc
随机推荐
Blocking queue for concurrent programming
刷题-洛谷-P1152 欢乐的跳
hcip第七天笔记
运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?
手写jdbc的使用步骤?
Audio and video technology development weekly | 255
NoSQL, relational database, row and column database comparison and analogy
GCD details
0717RHCSA
hcip第十天笔记
Redux usage and analysis
百度搜索打击盗版网文站点,SEOer应该关注哪些问题?
leetcode--四数相加II
stable_ Baselines quick start
Numpy quick start
[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB
并发编程之并发工具集
Hcip day 6 notes
Uncaught SyntaxError: Octal literals are not allowed in strict mode.
[server data recovery] HP EVA server storage raid information power loss data recovery