#include<iostream> using namespace std; int main() { int v[100],n,i,x,m,a; cout<<"n= "; cin>>n; cout<<"x= "; cin>>x; cout<<"m= "; cin>>m; for(i=1;i<=n;i++) { cout<<"v["<<i<<"]= "; cin>>v[i]; } for(i=1;i<=n;i++) { if(v[i]==x) { n=n+1; a=i; for(i=n;i>a;i--) { v[i]=v[i-1]; } v[i-1]=m; } } for(i=1;i<=n;i++) { cout<<v[i]<<" "; } } |
|
|