include stdafx include math include iostream using namespace std int i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "stdafx.h"
//#include "math.h"
#include <iostream>
using namespace std;
int f (int *a , int n, int k)
{ int *b= new int [k];
for (int i=0; i<k;i++) b[i]=a[i];
for (int i=0; i<k;i++)
for (int j=k-i-1; j<n-i-1;j++)
a[j]=a[j+1];
int l=0;
for (int i=n-k; i<n;i++)
a[i]=b[l++];
return 0;
}
void main()
{ int n,k;
cin>>n;
int * a= new int [n];
for (int i=0; i<n;i++) cin>>a[i];
cin>>k;
f(a,n,k);
for (int i=0; i<n;i++) cout<<a[i]<<' ';
delete []a;
}