#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char s[]="abcdefgh";
int i,j,k;
int b;
b=strlen(s);//get the length;
for(i=0;i<=b;i++)//make a loop to find all the different elements by define i!=j and so on;
{
for(j=i+1;j<=b-1;j++)
{
for(k=j+1;k<=b-1;k++)//notice that it couldn't greater than b-1,or it will be NULL when k is equal to strlen(s);
{
cout<<"the three elements set "<<"{"<<s[i]<<","<<s[j]<<","<<s[k]<<"}"; //output the sets
cout<<endl;
}
}
}
system ("pause");
return 0;
}
//sample output :
the three elements set {a,b,c}
the three elements set {a,b,d}
the three elements set {a,b,e}
the three elements set {a,b,f}
the three elements set {a,b,g}
the three elements set {a,b,h}
the three elements set {a,c,d}
the three elements set {a,c,e}
the three elements set {a,c,f}
the three elements set {a,c,g}
the three elements set {a,c,h}
the three elements set {a,d,e}
the three elements set {a,d,f}
the three elements set {a,d,g}
the three elements set {a,d,h}
the three elements set {a,e,f}
the three elements set {a,e,g}
the three elements set {a,e,h}
the three elements set {a,f,g}
the three elements set {a,f,h}
the three elements set {a,g,h}
the three elements set {b,c,d}
the three elements set {b,c,e}
the three elements set {b,c,f}
the three elements set {b,c,g}
the three elements set {b,c,h}
the three elements set {b,d,e}
the three elements set {b,d,f}
the three elements set {b,d,g}
the three elements set {b,d,h}
the three elements set {b,e,f}
the three elements set {b,e,g}
the three elements set {b,e,h}
the three elements set {b,f,g}
the three elements set {b,f,h}
the three elements set {b,g,h}
the three elements set {c,d,e}
the three elements set {c,d,f}
the three elements set {c,d,g}
the three elements set {c,d,h}
the three elements set {c,e,f}
the three elements set {c,e,g}
the three elements set {c,e,h}
the three elements set {c,f,g}
the three elements set {c,f,h}
the three elements set {c,g,h}
the three elements set {d,e,f}
the three elements set {d,e,g}
the three elements set {d,e,h}
the three elements set {d,f,g}
the three elements set {d,f,h}
the three elements set {d,g,h}
the three elements set {e,f,g}
the three elements set {e,f,h}
the three elements set {e,g,h}
the three elements set {f,g,h}
Press any key to continue . . .
组合数
最新推荐文章于 2024-07-31 11:11:45 发布