- 数组插入元素
why......
- 2024-11-9 22:35:11 @
佬们帮忙看看吧求求了
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n , a;
cin >> n;
int num[10000];
for (int i = 0 ; i < n ; i ++)
{
cin >> a;
num[i] = a;
}
int m;
cin >> m;
int x , y;
for(int i = 0 ; i < m ; i ++)
{
for (int i = 0 ; i < n ; i ++)
{
cout << num[i];
cout << " ";
}
cin >> x >> y;
for(int ii = n ; ii > x ; ii --)
{
num[ii] = num[ii - 1];
}
num[x] = y;
n = n + 1;
}
for (int i = 0 ; i < n ; i ++)
{
cout << num[i];
cout << " ";
}
}
1 comments
-
BlueCat LV 2 @ 2024-11-13 13:29:13Edited
@高2027届赵柯翔 (ZKXWTF) 数组开小ub了,改成20010就好了,而且你中间为什么要输出?要求输出最终的,19~23去掉
- 1
Information
- ID
- 588
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 4
- Tags
- # Submissions
- 128
- Accepted
- 56
- Uploaded By