赞
踩
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[100];
- int n,q,x;
- cin>>n>>q>>x;
- for(int i= 0;i<n;i++)
- {
- cin>>a[i];
- }
- int p = 0;
-
- for(int i =0;i<n;i++)
- {
- if(a[i]==q)
- {
- p = i;
- break;
- }
- }
- p++;
- for(int i = n-1;i>=p;i--)
- {
- a[i+1] = a[i];
- }
- a[p] =x;
- n++;
- for(int i = 0;i<n;i++)
- {
- cout<<a[i]<<" ";
- }
-
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[14010];
- int v,n;
- cin>>v>>n;
- for(int i= 0;i<n;i++)
- {
- cin>>a[i];
- }
- int p = -1;
- for(int i = 0;i<n;i++)
- {
- if(a[i]>=v)
- {
- p= i;
- break;
- }
- }
- for(int i = n-1;i>=p;i--)
- {
- a[i+1] = a[i];
- }
- a[p] = v;
- n++
-
- for(int i = 0;i<n;i++)
- {
- cout<<a[i]<<" ";
- }
- return 0;
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[100];
- int n;
- cin>>n;
- for(int i = 0;i<n;i++)
- {
- cin>>a[i];
- }
- int mi = a[0];
- int mii = 0;
- for(int i = 0;i<n;i++)
- {
- if(mi>a[i])
- {
- mi = a[i];
- mii = i;
- }
- }
- for(int i = mii;i<n;i++)
- {
- a[i] = a[i+1];
- }
- n--;
- for(int i = 0;i<n;i++)
- {
- cout<<a[i]<<" ";
- }
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
最大数
- #include<iostream>
- using namespace std;
- int main()
- {
- int a[100];
- int n;
- cin>>n;
- for(int i = 0;i<n;i++)
- {
- cin>>a[i];
- }
- int mi = a[0];
- int mii = 0;
- for(int i = 0;i<n;i++)
- {
- if(mi<a[i])
- {
- mi = a[i];
- mii = i;
- }
- }
- for(int i = mii;i<n;i++)
- {
- a[i] = a[i+1];
- }
- n--;
- for(int i = 0;i<n;i++)
- {
- cout<<a[i]<<" ";
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。