为什么不行?
2025-09-15 19:29:12
发布于:浙江
36阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,s[7];
for(int i=0;i<=7;i++){
cin>>a>>b;
s[i]=a+b;
}
int x=-1;
for(int i=0;i<=7;i++){
if(s[i]>x){
x=s[i];
}
}
cout<<x;
return 0;
}
why?
全部评论 2
我Python代码都比你快!
代码如下:
l=[]
inp=[]
unhappy=[]
for i in range(7):
inp=input().split(" ")
inp[0]=int(inp[0])
inp[1]=int(inp[1])
l.append(inp)
for i in l:
if sum(i)>7:
unhappy.append(sum(i))
else:
unhappy.append(0)
if sum(unhappy)==0:
print(0)
else:
x=max(unhappy)
for i in range(len(unhappy)):
if unhappy[i]==x:
print(i+1)
break2025-12-21 来自 北京
0#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b;
int max_val=-1;
int day=0;
for (int i=0;i<7;i++) {
cin>>a>>b;
int t=a+b;
if (t>8) {
if (t>max_val) {
max_val=t;
day=i+1;
}
}
}
if (day==0) {
cout<<0;
} else {
cout<<day;
}
return 0;
}2025-09-15 来自 上海
0别问,问就是太闲了
2025-09-15 来自 上海
0













有帮助,赞一个