#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
pair<vector<int>, vector<int>> createArrays(){
vector<int> first(rand() % 13000);
vector<int> second(rand() % 13000);
generate(first.begin(), first.end(), rand);
generate(second.begin(), second.end(), rand);
return make_pair(first, second);
}
int main(){
clock_t start;
clock_t total1 = 0;
clock_t total2 = 0;
bool isMismatch = false;
srand(time(nullptr));
for (auto i = 0; i < 3; ++i){
auto testValues1 = createArrays();
auto testValues2 = testValues1;
auto test = rand();
//test1
start = clock();
{
const auto size = testValues1.first.size();
testValues1.first.resize(size * testValues1.second.size());
for (int i = testValues1.first.size() - 1; i >= 0; --i){
testValues1.first[i] = testValues1.first[i % size] + testValues1.second[i / size];
}
}
total1 = clock() - start;
//test2
start = clock();
{
auto n = testValues2.first.size();
testValues2.first.resize(n * testValues2.second.size());
for (auto i = n, j = testValues2.first.size(); i != 0; --i)
{
for (auto it = testValues2.second.rbegin(); it != testValues2.second.rend(); ++it)
{
testValues2.first[--j] = testValues2.first[i - 1] + *it;
}
}
}
total2 = clock() - start;
for (auto i = 0; i < testValues1.first.size(); ++i){
isMismatch = testValues1.first[i] != testValues2.first[i];
}
if (isMismatch){
cout << "OH BAD!";
}
}
cout << "Test 1: " << total1 << endl << "Test 2: " << total2 << endl;
return 0;
}