Advertisement
Loloped

Untitled

Feb 20th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  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;
  16.     if (k<0 || k>n-1)
  17.         cout <<"error";
  18.     else {for (int i=k; i<n-1; i++) a[i]=a[i+e+1];
  19.     n--;
  20.     for (int i=0; i<n; i++) cout << a[i]<<"\t";}
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement