队列2--集合
一、心得
二、题目及分析
求1, 2x+1和3x+1队列的第100个数
三、代码及结果
1 //求1, 2x+1和3x+1队列的第100个数 2 //依次把队列中的2x+1和3x+1都取了 3 #include4 using namespace std; 5 6 int q[200]; 7 8 int main(){ 9 int head=1;10 q[head]=1;11 int two=1,three=1;12 //求第100个数 13 for(int i=1;i<=100;i++){14 int x2=2*q[two]+1;15 int x3=3*q[three]+1; 16 if(x2==x3){17 q[++head]=x2;18 two++,three++;19 }20 else if(x2
前十项