| sbgreen6592 (21) | |
|
So I need to write a program that produces 10 random permutations of the numbers 1 to 10. My program only gives one line. I need ten. Help! #include <iostream> using namespace std; int main() { int a[10] = {1,2,3,4,5,6,7,8,9,10}; int b[10]; int index; int b_index = 0; int count = 10; int i; for (i = 0; i < 10; ++i) { {index = rand() % 10; b[i] = a[index]; a[index] = a[count - 1]; --count;} for (i = 1; i cout << b[i] << endl; } system("PAUSE"); return 0; } | |
|
|
|
| Darkmaster (341) | |
| this doesnt solve your problem, but why dont you use b[i] = rand() % 10; | |
|
|
|