-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenum.cpp
More file actions
54 lines (40 loc) · 709 Bytes
/
enum.cpp
File metadata and controls
54 lines (40 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int N, lb, ub;
int *a;
void nested_loop(int n, int k);
ofstream a_b_values("a_b_vals.dat",ios::out);
int main(int argc, char** argv)
{
if( argc != 4 ) {
cout << "Invalid use lol" << endl;
return 1;
}
N = atoi( argv[ 1 ] );
a = new int[N]; //hold the value of the n variables
lb = atoi( argv[2]);
ub = atoi(argv[3]);
int n=N-1;
nested_loop(n,ub-lb+1);
return 0;
}
void nested_loop(int n, int k)
{
int i,j;
if(n<0)
{
for(j=0;j<N;j++)
cout<<a[j]+lb-1<<"\t";
cout<<endl;
}
else
{
for(i=1;i<=k;i++)
{
a[n]=i;
nested_loop(n-1,i);
}
}
}