201604- 2俄罗斯方块
// An highlighted block
#include <bits/stdc++.h>
using namespace std;
int a[16][11];
int b[5][5];
int row;
struct point{
int x,y;
}p[4];
int main()
{
for(int i=1;i<=15;i++)
for(int j=1;j<=10;j++)
cin>>a[i][j];
int m=0;
for(int i=1;i<=4;i++)
for(int j=1;j<=4;j++)
{
cin>>b[i][j];
if(b[i][j]==1){
p[m].x=i;
p[m].y=j;
m++;
}
}
cin>>row;
for(int i=0;i<=3;i++)
{
p[i].y+=row-1;
}
int height;
int j;
for(j=-2;j<=15;j++){
int judge = 0;
for(int k=0;k<=3;k++)
{
if(p[k].x+j-1<0){
break;
}
else if(p[k].x+j-1>15){
judge = 1;
break;
}
else if(a[p[k].x+j-1][p[k].y]==1){
judge = 1;
break;
}
}
if(judge == 1){
break;
}
}
height = j;
for(int i=0;i<4;i++){
if(p[i].x+height-2>=1&&p[i].x+height-2<=15)
a[p[i].x+height-2][p[i].y]=1;
}
for(int i=1;i<=15;i++)
{
for(int j=1;j<=10;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
system("pause");
return 0;
}