G
Gaijinco
I been thinking about this topic for a long time. The best I have done
is the following code:
#include <iostream>
using namespace std;
#include <cmath>
int main(){
const int SIZE=3;
int set[SIZE]={1,2,5};
for(int i=pow(SIZE,2)-1; i>=0; --i){
int index=2;
int n=i;
cout << "{ ";
while(n>0){
if(n%2)
cout << set[index] << " ";
--index;
n/=2;
}
cout << "}" << endl;
}
system("pause");
return 0;
}
However it seems bulky to me. There is another way?
Thank you!
is the following code:
#include <iostream>
using namespace std;
#include <cmath>
int main(){
const int SIZE=3;
int set[SIZE]={1,2,5};
for(int i=pow(SIZE,2)-1; i>=0; --i){
int index=2;
int n=i;
cout << "{ ";
while(n>0){
if(n%2)
cout << set[index] << " ";
--index;
n/=2;
}
cout << "}" << endl;
}
system("pause");
return 0;
}
However it seems bulky to me. There is another way?
Thank you!