4 条题解

  • 2
    @ 2022-7-25 11:56:46

    水题啊~

    正经点的写法:

    重点注意[敲黑板] sort排序后一个参数要传到要排的下一个

    e.g. 以本题为例,sort排序标到a+6.

    某位同学:数组里不是a[6]不存在吗?不过没关系,就算你这里没有,那sort会在原地排的

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int bp,dls[6];
    	cin>>bp;
    	for(int i=1;i<=5;i++) cin>>dls[i];
    	sort(a+1,a+6);
    	cout<<a[6]-bp+1<<endl;
    	return 0;
    }
    

    懒狗的写法:

    这没什么好讲的,max的套WA嘛 owo

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a,b,c,d,e,f;
    	cin>>a>>b>>c>>d>>e>>f;
    	cout<<max(b,max(c,max(d,max(e,f))))-a+1<<endl;
    	return 0;
    }
    
    • 1
      @ 2022-8-13 19:20:19

      ε=(´ο`*)))唉,没办法,我太懒了😂😄 😄

      #include<bits/stdc++.h>
      using namespace std;
      
      int main(){
      	int a,b,c,d,e,f;
      	cin>>a>>b>>c>>d>>e>>f;
      	cout<<max(b,max(c,max(d,max(e,f))))-a+1;
      }
      
      • 1
        @ 2022-5-27 19:50:20
        #include <algorithm>
        using namespace std;
        	int a[6],b;
        int main(){
        	for(int i=1;i<=6;i++){
        		cin>>a[i];
        	}
        	int b=a[1];
        	sort(a,a+7);
        	cout<<a[6]-b+1;
        	return 0;
        }
        

        注:sort快速排序起始终点需要特别注意,我就在栽了好久 sort快排用法博客: [sort函数数组排序(c++方法)_Serendipity486的博客-CSDN博客_c++数组排序](https://)

      • -3
        @ 2022-7-22 20:34:37

        #include<iostream> #include<algorithm> using namespace std; int main(){ int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f; int B=max(f,max(e,max(d,max(c,b)))) ; int g=B-a+1; cout<<g; return 0; }

        • @ 2022-8-13 19:21:52

          太复杂了

      • 1

      信息

      ID
      14
      时间
      1000ms
      内存
      256MiB
      难度
      3
      标签
      递交数
      129
      已通过
      72
      上传者