【发布时间】:2014-09-06 16:52:27
【问题描述】:
//16行
0000 0000
0001 1000
0010 0001
0011 1100
0100 0010
0101 0101
0110 1001
0111 1110
1000 0100
1001 0110
1010 1010
1011 0111
1100 0011
1101 1011
1110 1101
1111 1111
我创建了两个向量
std::vector<std::bitset<4> > a 第一列
std::vector<std::bitset<4> > b 第二列
我想用这些向量形成循环
示例:
a[0] == b[0] --> display it
a[1] != b[1] -->
//queue function which returns queue
push a[1],b[1] into queue --> check the value of b[1] in `vector a`return the position of b[1] in a --> push value in b at position return -- > repeat it until queue.back() == queue.front() -- return the entire queue
//end of queue
a[0] == b[0] -- > display it
a[1] != b[1] -->
q1 <- a[1] , q1 <- b1 --> q1 = {a[1],b[1],....}
// function begin
then check value of b[1] in `a` and return the position `8` --> q1<-b[8] --> q1{a[1],b[1],b[8],...}
then check value of b[8] in `a and return the position `4` --> q1<-b[4] --> q1(a[1],b[1],b[8],b[4],.}
repeat it until last value of b[position] == q1.front();
return the entire queue q1--> {a[1],b[1],b[8],b[4],b[2]}
//函数结束
我想使用一个函数,它在执行完所有操作后返回整个队列。是否可以返回向量值队列。如果是这样,任何人都可以给我一个示例,说明如何使用上面给出的示例对其进行编码
if(a.at(0) == b.at(0))
{
std:: cout << "a==b";
}
else
{
//queue function starts here
//do some operations
//return the queue
}
【问题讨论】: