Dateien nach „BSP_1_E“ hochladen
This commit is contained in:
parent
dde42b7628
commit
56192999bd
4 changed files with 252 additions and 0 deletions
107
BSP_1_E/bsp_1_e.cpp
Normal file
107
BSP_1_E/bsp_1_e.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#include "bsp_1_e.h"
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<int> sortvec(const vector<int> &x, const vector<int> &y)
|
||||
{
|
||||
vector<int> result = x;
|
||||
for(size_t k = 0; k<y.size(); ++k)
|
||||
{
|
||||
auto pos = lower_bound(result.begin(), result.end(), y[k]);
|
||||
result.insert(pos, y[k]);
|
||||
}
|
||||
// check if sorted
|
||||
if(is_sorted(result.begin(), result.end()) == 0)
|
||||
{
|
||||
cout << "FEHLER - nicht sortiert" << endl;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
vector<int> genrandvec(const int &n)
|
||||
{
|
||||
vector<int> v;
|
||||
srand((unsigned) time(NULL));
|
||||
for(int k=0; k<n; ++k)
|
||||
{
|
||||
int random = 1 + (rand() % n);
|
||||
v.push_back(random);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
vector<int> gensortvec(const int & n)
|
||||
{
|
||||
vector<int> v;
|
||||
for(int k = 0; k<n; ++k)
|
||||
{
|
||||
v.push_back(k+1);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
list<int> sortlist(const list<int> &x, const list<int> &y)
|
||||
{
|
||||
list<int> result = x;
|
||||
for(auto it = y.begin(); it != y.end(); ++it)
|
||||
{
|
||||
auto pos = lower_bound(result.begin(), result.end(), *it);
|
||||
result.insert(pos, *it);
|
||||
}
|
||||
// check if sorted
|
||||
if(is_sorted(result.begin(), result.end()) == 0)
|
||||
{
|
||||
cout << "FEHLER - nicht sortiert" << endl;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
list<int> genrandlist(const int &n)
|
||||
{
|
||||
list<int> v;
|
||||
srand((unsigned) time(NULL));
|
||||
for(int k=0; k<n; ++k)
|
||||
{
|
||||
int random = 1 + (rand() % n);
|
||||
v.push_back(random);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
list<int> gensortlist(const int & n)
|
||||
{
|
||||
list<int> v;
|
||||
for(int k = 0; k<n; ++k)
|
||||
{
|
||||
v.push_back(k+1);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
list<int> genlistfromvec(const vector<int> &v)
|
||||
{
|
||||
list<int> a;
|
||||
for(size_t k=0; k<v.size(); ++k)
|
||||
{
|
||||
a.push_back(v[k]);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue