1 solutions

  • 0
    @ 2023-1-17 22:50:31
    #include<bits/stdc++.h>
    using namespace std;
    int a[1010],n,x,y,i,p;
    int main()
    {
    	cin >> n >> x >> y;
    	for(i = 1; i <= n; i++){
    		cin >> a[i];
    		if(a[i] == x) p = i;
    	}
    	for(i = n; i > p; i--){
    		a[i+1] = a[i];
    	}
    	a[p+1] = y;
    	n++;
    	for(i = 1; i <= n; i++) cout << a[i] << " ";
    	return 0;
    }
    
    
    
    • 1

    Information

    ID
    557
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    4
    Uploaded By