Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[°ÝÃD]»¼°j°ÝÃD

0 views
Skip to first unread message

good

unread,
Apr 9, 2004, 4:50:31 AM4/9/04
to
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<windows.h>
void main()
{
int n,j;
char str[100];int bin[100];
cout<<"ENTER THE NUMBER OF CHARACTESRS";
cin>>n;

cout<<"PLEASE ENTER SINGLE CHARCTERS";//char array .press return after each entry
for(int i=0;i<n;i++)//inputting
cin>>str[i];
system("cls");
//----------------------------------------------------------------------------
for(i=0;i<n;i++)//n輸入几個就几個
bin[i]=0;

i=0;
cout<<"POWERSET IS"<<endl;//powerset is set containing subsets of given set
cout<<"{";

while(i<exp(n*log(2)))//no: of subset is 2^n where n is the no:of elements
{
cout<<endl;
j=0;
cout<<"{";
for(int k=0;k<n;k++)
{
if(bin[k]==1)
cout<<str[k];//outputs if bin[k]=1
}
cout<<"}";
j=0;
bin[j]=bin[j]+1;
while(bin[j]>1) //generating binary sequence,000,001,010,011.....
{
bin[j]=bin[j]-2;
j=j+1;
bin[j]=bin[j]+1;
}
i=i+1;
}
cout<<"}"<<endl;
}
以上是我在網路上找到的答案..

--
有問題可以寫信給我physic...@bbs.dyu.edu.tw
--
[1;32m※ Origin: [33m大葉大學戀戀紅城 [37m<bbs.dyu.edu.tw> [m
[1;32m※ From : [36msw59-244-244.adsl.seed.net.tw [m

0 new messages