Probleme beim cout Befehl ?

Hatte mal Langeweile, hier mal einen Algorithmus der das ganze recht
flott berechnen sollte...

Code:
#include <iostream>
#include <vector>

using namespace std;

/**
 * @author RedWing
 * this function returns a vector filled with a randomized order of the given intervall
 * in a pretty good efficient way...
 * please call srand before calling this function
 * @param min: the minimum of the intervall
 * @param max the maximum of the intervall
 * @param result the resulting vector filled with the randomized order of the intervall
 */
void randomize(int min, int max, vector<int>& result){

        if((max - min) > 0){
                int rand_er = rand() % ((max - min) + 1) + min;
                randomize(min, rand_er - 1, result);
                randomize(rand_er + 1, max, result);
                result.push_back(rand_er);
        }
        else if((max - min)  == 0)
                result.push_back(max);
}

int main(){
        vector<int> res;
        srand(time(NULL));
        randomize(1,15,res);
        for(int i = 0; i < res.size(); i++)
                cout << res[i] << endl;
}

Gruß

RedWing
 
Zurück