5 条题解
-
0
#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
#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
#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
#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
#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
- 上传者