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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
//============================================================================
// Name : dsafnaskfj.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int arrayA(int theArray[],int size)
{
cout << "Array: " << '{';
int i = 0;
while (i < size)
{
cout << theArray[i];
if (i < size-1){cout << ',';}
i++;
}
cout << '}' << endl << "Want to delete something (y/n)? ";
char ansr;
cin >> ansr;
if (ansr == 'y')
{
cout << "Offset to delete? ";
int offset;
cin >> offset;
return offset;
}
else if (ansr == 'n')
{
cout << "Goodbye!";
}
return 0;
}
int arrayB(int theArray2[], int size, int offset)
{
if ((offset >= size)||(offset < 0)){ cout << "Sorry, cannot delete that." << endl; return size;}
theArray2[offset]=theArray2[size-1];
size--;
return size;
}
int main() {
int N = 10;
int y;
int fling[]={1,2,3,4,5,6,7,8,9,10};
do{
y = arrayA(fling, N);
N = arrayB(fling, N, y);
}while ((N > 0)&&(y != 0));
return 0;
}
|