C++用多线程实现双人俄罗斯方块

#include?<iostream>

#include?<vector>

#include?<algorithm>

using?namespace?std;

int?is_right(int?a[],int?k)

{

int?jian_ge=a[1]-a[0];

int?count_num=0;

for(int?i=0;?i<k-1;?i++)

{

if(a[i+1]-a[i]==jian_ge)

{

count_num++;

}

}

return?count_num==k-1?true:false;

}

int?main()

{

int?i;

cin>>i;

vector?<char>?result;

vector?<char>?::?iterator?it;

for(int?j=1;?j<=i;?j++)

{

int?k;

cin>>k;

int?a[k];

for(int?m=0;?m<k;?m++)

{

cin>>a[m];

}

if(is_right(a,k)==1)

{

result.push_back('Y');

}

else

{

result.push_back('N');

}

}

//reverse(result.begin(),result.end());

for(it=result.begin();?it!=result.end();?it++)

{

cout<<*it<<endl;

}

return?0;

}