俄罗斯方块60分
Posted fishegg
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了俄罗斯方块60分相关的知识,希望对你有一定的参考价值。
#include<iostream> using namespace std; int main() { int a[15][10]; int b[5][5]; int height[4] = { 0,0,0,0 }; int leftmargin; int max = 15; int i, j, k; int tmp; int x, y; bool flag; for (i = 0; i<15; i++) for (j = 0; j<10; j++) cin >> a[i][j]; leftmargin = 3; for (i = 0; i<4; i++) { for (j = 0; j<4; j++) { cin >> b[i][j]; if (b[i][j] == 1 && j < leftmargin) leftmargin = j; } } cin >> x; y = 0; for (i = 0; i < 4; i++) { if (x >= leftmargin) { for (j = x - leftmargin; j < x - leftmargin + 4; j++) a[i][j] = b[i][j - x + leftmargin]; } else { for (j = x; j < x - leftmargin + 4; j++) a[i][j] = b[i][j - x + leftmargin]; } } for (j = x; j < x + 4; j++) { flag = false; for (i = 0; i < 15; i++) { if (a[i][j] == 1 && a[i+1][j] == 0 && i < 4) { flag = true; } else if (a[i][j] == 0 && flag == true) { height[j - x]++; } else if (a[i][j] == 1 && i >= 4) break; } } for (i = 0; i < 4; i++) { if (height[i] < max && height[i] != 0) max = height[i]; } for (i = 0; i < 4; i++) for (j = 0; j < 10; j++) a[i][j] = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (b[i][j] != 0) a[i + max][j + x - leftmargin] = b[i][j]; } } for (i = 0; i < 15; i++) { for (j = 0; j < 10; j++) { cout << a[i][j] << " "; } cout << endl; } return 0; }
以上是关于俄罗斯方块60分的主要内容,如果未能解决你的问题,请参考以下文章