1 solutions
-
0
#include<bits/stdc++.h> using namespace std; int a[110],n,p,ma = INT_MIN,y,i; int main() { cin >> n; //找出最大数的下标 for(i = 1; i <= n; i++){ cin >> a[i]; if(a[i] > ma){ ma = a[i]; p = i; } } cin >> y; //从最大的数开始所有的数后移一位 for(i = n; i > p; i--){ a[i+1] = a[i]; } //插入这个数 a[i+1] = y; n++; //输出结果 for(i = 1; i <= n; i++) cout << a[i] << " "; return 0; }
- 1
Information
- ID
- 554
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 10
- Tags
- # Submissions
- 6
- Accepted
- 6
- Uploaded By