I cant figure out how to finish this assigment =\
Help >.<
Hm.. Sry for the other language used in it =\
This is the language we are being taugh in >.<'
Cik skaitlu ivadiisiet? = How many numbers to enter?
Ievadiet skaitlus = entered numbers
Ievadiitais masiivs = entered array
Cik skaitlu iznjemt no massiva? = How many number to take away from the array?
Iznjem = taken
massivs = array
garums - lengh
I know i might not amazing with arrays, but i think i did the job correct, sloppy but works xD
Anyways, need help with how gettin the following 2 lines...
1) The numbers you took from the array : ... .... .... ....
2)The numbers left in the array: .... ... ... ... (the trick for the 2nd one is they need to be in ascending order >.>)
#include <iostream>
using namespace std;
void printarray (int arg[], int length) {
for (int n=0; n<length; n++)
cout << arg[n] << " ";
cout << "\n";
}
int main()
{
int garums = 0;
int sk;
int *mass;
int iznsk, izn;
cout << "Cik skaitlu isvadiisiet? ";
cin >> garums;
cout << endl << endl;
mass = new int [garums];
if (*mass == 0)
cout << "Error!" << endl;
else{
cout << "Ievadiet " << garums <<" skaitlus - ";
for(int i=0; i<garums; i++){
cin >> mass[i];
}
cout << endl <<"Ievadiitais masiivs: ";
printarray (mass, garums);
cout << endl;
cout << "Cik skaitlu iznjemt no massiva? ";
cin >> iznsk;
for (int j=0; j<iznsk; j++){
cout << "Iznjem ";
cin >> izn;
cout << endl;
for (int k=0; k<garums; k++){
if (mass[k] == izn)
for(int l=k ;l<garums; l++){
mass[l] = mass[l+1];
}
}
garums = garums -1;
printarray (mass,garums);}
}
system("PAUSE");
return 0;
}