关于bitset定义的VC实验

来源:互联网 发布:天津广电网络 数字电视 编辑:程序博客网 时间:2024/05/17 02:07

庭博网校QQ:14280784    86974558

学习内容和顺序:

1、C语言;

2、C++语言;

3、VC++;

4、win32编程;

5、数据库编程;

6、网络编程;

7、多线程编程。

一年2500元。每天2小时上课

/*bitset的定义*/
/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b;//定义15位的二进制
 cout<<b<<endl;//显示
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b(15);
 cout<<b<<endl;
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<32> b(0xf0f0);
 cout<<b<<endl;
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b("1010110");
 cout<<b<<endl;
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 string s("101101");
 bitset<3> b(s);
 cout<<b<<endl;
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 string s("1111000101010");
 bitset<15> b(s,2,6);//从s[2]起,取6个
 cout<<b<<endl;
 getchar();
 return 0;
}
*/

/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 string s;
 s="1010111110001011";
 bitset<10> b(s,s.size()-4);//从倒首第4个取到尾
 cout<<b<<endl;
 getchar();
 return 0;
}*/

/*
最否存在署为1的二进制位
*/
/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b("000000");
 if(b.any()) cout<<"存在为1的位";
 else cout<<"不存在为1的位";
 getchar();
 return 0;
}
*/

/*
功能:将二进制转为10进制
*/
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b("1010");
 unsigned long int w=b.to_ulong();//把C++转为了C方式
 cout<<w;
 getchar();
 return 0;
}


/*
#include "iostream"
#include "bitset"
using namespace std;
int main()
{
 bitset<15> b;
 cin>>b;//用流方式输入位集
 rewind(stdin);
 cout<<b;
 getchar();
 return 0;
}*/

 

 

原创粉丝点击