5 条题解

  • 0
    @ 2023-3-19 10:30:37

    #include<bits/stdc++.h> using namespace std; int a[105]; int main(){ int n,y,max,b; cin>>n>>a[1]; max = a[1],b=2; for(int i=2;i<=n;i++) { cin>>a[i]; } cin>>y; for(int i=1;i<=n;i++) { if(a[i]>max){ max = a[i]; b = i+1; } } for(int i=n+1;i>=b+1;i--) { a[i]=a[i-1]; } a[b]=y; for(int i=1;i<=n+1;i++) { cout<<a[i]<<" "; } cout<<endl; return 0; }

    • -1
      @ 2022-11-5 15:12:47

      #include<bits/stdc++.h>

      using namespace std;

      int a[114514];

      int main(){

      int n,y;

      cin>>n;

      for(int i=1;i<=n;i++)

      cin>>a[i];

      cin>>y;

      int max=a[1],maxn=1;

      for(int i=2;i<=n;i++){

      if(a[i]>max){

      max=a[i];maxn=i; }

      } for(int i=n+1;i>=maxn+2;i--)

      a[i]=a[i-1];

      a[maxn+1]=y;

      for(int i=1;i<=n+1;i++) cout<<a[i]<<" ";

      return 0; }

      • -2
        @ 2022-11-5 14:31:32

        #include<bits/stdc++.h> using namespace std; int a[114514]; int main(){ int n,y,max,b; cin>>n>>a[1]; max = a[1],b=2; for(int i=2;i<=n;i++){ cin>>a[i]; } cin>>y; for(int i=1;i<=n;i++){ if(a[i]>max){ max = a[i]; b = i+1; } } for(int i=n+1;i>=b+1;i--){ a[i]=a[i-1]; } a[b]=y; for(int i=1;i<=n+1;i++){ cout<<a[i]<<" "; } cout<<endl; return 0; }

        • -3
          @ 2022-11-5 11:16:37

          #include<bits/stdc++.h> using namespace std; int a[105]; int main(){ int n,y,max,b; cin>>n>>a[1]; max = a[1],b=2; for(int i=2;i<=n;i++){ cin>>a[i]; } cin>>y; for(int i=1;i<=n;i++){ if(a[i]>max){ max = a[i]; b = i+1; } } for(int i=n+1;i>=b+1;i--){ a[i]=a[i-1]; } a[b] = y; for(int i=1;i<=n+1;i++){ cout<<a[i]<<" "; } cout<<endl; return 0; }

          • -4
            @ 2022-11-5 13:38:30
            #include<bits/stdc++.h>
             using namespace std;
             int a[105];
             int main(){
             int n,y,max,b;
             cin>>n>>a[1];
             max = a[1],b=2;
             for(int i=2;i<=n;i++){
             cin>>a[i];
             }
             cin>>y;
             for(int i=1;i<=n;i++){ 
             if(a[i]>max){
             max = a[i]; 
             b = i+1;
             }
             }
             for(int i=n+1;i>=b+1;i--){
             a[i]=a[i-1];
             }
             a[b]=y;
             for(int i=1;i<=n+1;i++){
             cout<<a[i]<<" ";
             }
             cout<<endl;
             return 0;
             }
            
            • 1

            信息

            ID
            214
            时间
            1000ms
            内存
            16MiB
            难度
            1
            标签
            递交数
            52
            已通过
            37
            上传者