64,654
社区成员
发帖
与我相关
我的任务
分享
#include "iostream"
#include "vector"
using namespace std;
typedef vector <bool*> INTVECTOR;
int main()
{
INTVECTOR theVector;
bool b1[3] = {true, true ,true};
bool b2[4] = {false, true, true, false};
theVector.push_back(b1);
theVector.push_back(b2);
for (int i = 0; i < 3; ++i)
cout<<theVector[0][i]<<" ";
cout<<endl;
for (int i = 0; i < 4; ++i)
cout<<theVector[1][i]<<" ";
cout<<endl;
return 0;
}
--------
1 1 1
0 1 1 0
请按任意键继续. . .
#include <iostream>
#include <vector>
using namespace std;
typedef vector <bool*> INTVECTOR;
int main(){
INTVECTOR theVector;
bool b1[3]={1,1,1} ;
bool b2[4]={0,1,1,0};
theVector.push_back(b1);
theVector.push_back(b2);
cout <<*theVector.at(0);//第一个数组的[0]元素
cout <<*(theVector.at(1)+1);//第一个数组的[1]元素
return 0;
}