View difference between Paste ID: FjZf0ViJ and ScQ2KMhB
SHOW: | | - or go back to the newest paste.
1
#include "stdafx.h"
2
#include <iostream>
3
4
using namespace std;
5
int main()
6
{
7
	int n; cout<<"n="; cin>>n;
8
	int *a=new int [n];
9
	for (int i=0; i<n; i++)
10
	{
11
		cout<<"a["<<i<<"]="; cin>>a[i];
12
	}
13
	int k; cout<<"k="; cin >>k;
14
	int p; cout<<"p="; cin >>p;
15-
	int e=p-k;
15+
	int e;
16-
	if (k<0 || k>n-1)
16+
	if (k>p) {e=k; k=p; p=e;}
17
	e=p-k;
18
	if (k<0 || k>n-1 || p<0 || p>n-1)
19
		cout <<"error";
20
	else {for (int i=k; i<n-1; i++) a[i]=a[i+e+1];
21
	n--;
22
	for (int i=0; i<n; i++) cout << a[i]<<"\t";}
23
	return 0;
24
}