• 俄罗斯方块50分


    #include<iostream>
    using namespace std;
    int main() {
    	int a[15][10];
    	int b[5][5];
    	int co[4][3];
    	int count;
    	int len, wid;
    	int oriy;
    	int dis;
    	int height[4] = { 0,0,0,0 };
    	int leftmargin;
    	int max = 15;
    	int i, j, k;
    	int tmp;
    	int x, y;
    	bool block=false;
    	for (i = 0; i<15; i++)
    		for (j = 0; j<10; j++)
    			cin >> a[i][j];
    	leftmargin = 3;
    	b[0][4] = b[1][4] = b[2][4] = b[3][4] = b[4][0] = b[4][1] = b[4][2] = b[4][3] = 0;
    	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;
    		}
    	}
    	for (i = 0; i < 4; i++) {
    		if (b[0][i] == 1)
    			b[0][4]++;
    		if (b[1][i] == 1)
    			b[1][4]++;
    		if (b[2][i] == 1)
    			b[2][4]++;
    		if (b[3][i] == 1)
    			b[3][4]++;
    		if (b[i][0] == 1)
    			b[4][0]++;
    		if (b[i][1] == 1)
    			b[4][1]++;
    		if (b[i][2] == 1)
    			b[4][2]++;
    		if (b[i][3] == 1)
    			b[4][3]++;
    	}
    	len = b[4][0];
    	wid = b[0][4];
    	for (i = 0; i < 4; i++) {
    		if (b[4][i] > len)
    			len = b[4][i];
    		if (b[i][4] > wid)
    			wid = b[i][4];
    	}
    	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 (i = 0; i < 4; i++) {
    		for (j = x; j < x + wid; j++) {
    			if (a[i][j] == 1) {
    				oriy = i;
    				break;
    			}
    		}
    		if (oriy = i)
    			break;
    	}
    	count = 0;
    	for (i = 0; i < 4; i++) {
    		if (count == 4)
    			break;
    		for (j = x; j < x + wid; j++) {
    			if (a[i][j] == 1) {
    				co[count][0] = j;
    				co[count][1] = i;
    				if (a[i + 1][j] == 1)
    					co[count][2] = 1;
    				else
    					co[count][2] = 0;
    				count++;
    			}
    		}
    	}
    	for (i = 0; i < 15; i++) {
    		for (k = 0; k < 4; k++) {
    			cout << "k" << k << " ";
    			if (co[k][2] != 1) {
    				cout << "cok1" << co[k][1] << "cok0" << co[k][0] << endl;
    				if (a[co[k][1] + 1][co[k][0]] == 1 || co[k][1] == 14) {
    					block = true;
    					break;
    				}
    			}
    		}
    		if (block)
    			break;
    		else {
    			for (j = 0; j < 4; j++)
    				a[co[j][1]][co[j][0]] = 0;
    			for (j = 0; j < 4; j++)
    				co[j][1]++;
    			for (j = 0; j < 4; j++)
    				a[co[j][1]][co[j][0]] = 1;
    		}
    	}
    	for (i = 0; i < 15; i++) {
    		for (j = 0; j < 10; j++) {
    			cout << a[i][j] << " ";
    		}
    		cout << endl;
    	}
    	system("pause");
    	return 0;
    }
    

      

  • 相关阅读:
    Poj2155Matrix二维线段树
    二维树状数组模板
    PAT-1014 Waiting in Line (30 分) 优先队列
    PAT-1012 The Best Rank (25 分) 查询分数对应排名(包括并列)
    PAT-1003 Emergency (25 分) 最短路最大点权+求相同cost最短路的数量
    PAT-1001 A+B Format (20 分) 注意零的特例
    利用requests和BeautifulSoup爬取菜鸟教程的代码与图片并保存为markdown格式
    菜鸟教程上的设计模式代码合集
    用python将项目中的所有代码(或txt)合并在一个文件中
    POJ 2485 Prim 找最长的边
  • 原文地址:https://www.cnblogs.com/fishegg/p/7376670.html
Copyright © 2020-2023  润新知