These are the last few errors in my code that I am having issues with. Please provide some direction or thought as to what to do to fix it.
generator.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
generator.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
generator.cpp(63) : fatal error C1004: unexpected end-of-file found
The original assignment :
Write a program that produces ten random permutations of the numbers 1 to 10. To generate a random permutation, you need to fill a vector with the numbers 1 to 10 so that no two entries of the vector have the same contents. You could do it by brute force, by calling rand_int until it produces a value that is not yet in the vector. Instead, you should implement a smart method.
Make a second array and fill it with the numbers 1 to 10. Then pick one of those at random, remove it, and append it to the permutation vector.
Repeat ten times.
#include <string>
#include <vector>
using namespace std;
class PermutationGenerator
{
public:
std::vector<int> randPermutation;
std::vector<int> intList;
Random ;*randSelection;
int listSize;
PermutationGenerator() //this(10);
{
}
PermutationGenerator(int lsize)
{
randSelection = new Random();
listSize = lsize;
intList = std::vector(listSize);
randPermutation = std::vector(listSize);
}
virtual std::vector<int> nextPermutation()
{
// Fill the ArrayList intList with the numbers 1 to 10
intList.clear();
for (int i = 1; i <= listSize; i++)
intList.push_back(i);
randPermutation.clear();
for (int i = 1; i <= listSize; i++)
{
// Pick a number at random using (using Random.nextInt(int),
// that removes a number from the intList.
int index = randSelection->nextInt(intList.size());
int number = intList.remove(index);
// Add and append the random number to the randPermutation ArrayList.
// Repeated listSize times
randPermutation.push_back(number);
}
return randPermutation;
}
static void main(std::string args[])
{
// Prints out the values of the returned ArrayList
PermutationGenerator *gen = new PermutationGenerator(10);
for (int i = 1; i <= 10; i++)
{
std::cout::put("List " + i + ": ");
std::vector<int> list = gen->nextPermutation();
puts(list);
}
}
}