void VlozitPrvek(int prvek);
void SeradPrvky(Razeni r);
int OdstranNNasobky(int zaklad);
void OdstranDuplicitu();
void ZamichejData();
void Vypis();
string toString();
int getInt(void);
friend ostream& operator <<(ostream& os, PraceSCisly&v)
{
int i = 1;
vector<int>::iterator it = v.cisla.begin();
for (it; it != v.cisla.end(); it++){
if (i == v.cisla.size()){
os << *it << endl;
}
else{
os << *it << ", ";
}
vector<int>::iterator it = cisla.begin();
for (it; it != cisla.end(); it++){
if (posledniNactene != *it){
novyVektor.push_back(*it);
}
posledniNactene = *it;
}
cisla = novyVektor;
}
int PraceSCisly::OdstranNNasobky(int zaklad){
if (zaklad != 0){
cout << "Odstranuji nasobky cisla: " << zaklad << endl;
int pocetDuplicit = 0;
vector<int> novyVektor;
vector<int>::iterator it = cisla.begin();
for (it; it != cisla.end(); it++){
if (*it % zaklad == 0){
pocetDuplicit++;
}
else{
novyVektor.push_back(*it);
}
}
cisla = novyVektor;
cout << "Pocet odstranenych duplicit: " << pocetDuplicit << endl;
return pocetDuplicit;
}
throw exception("Deleni nulou, nepripustne \n\n");
}
void PraceSCisly::Vypis(){
cout << "\nVypis cisel: ";
if (cisla.empty()){
cout << "Nejsou zadana zadna cisla" << endl;
}else {
vector<int>::iterator it = cisla.begin();
int i = 1;
for (it; it != cisla.end(); it++){
if (i == cisla.size()){
cout << *it << endl;
}
else{
cout << *it << ", ";
}
i++;
}
}
}
void PraceSCisly::ZamichejData(){
if (!cisla.empty()){
random_shuffle(cisla.begin(), cisla.end());
}
else{
throw exception("Seznam cisel je prazdny");
}
}
Please edit your post and put the code in code tags. Highlight the code and click the "<>" button on the right of the edit window. This will make it easier to comment on the code.
Then, please tell us what your specific question is. The subject indicates it's something to do with sorting, but can you be more specific?