标签:break turn else highlight bre scan cpp lse 训练
//算法训练——暗恋 //思路:枚举 #include<stdio.h> #define MAX 200 int map[MAX][MAX]; int judge(int x,int y,int cur){ //判断以(x,y)为左上角、长度为cur,能否构成一个纯色的正方形 int color; color = map[x][y]; for(int i=x;i<x+cur;i++){ for(int j=y;j<y+cur;j++){ if(color != map[i][j]) return 0; } } return 1; } int main(){ int i,j,curMax,maxWidth,row,col; scanf("%d%d",&row,&col); for(i=0;i<row;i++) for(j=0;j<col;j++) scanf("%d",&map[i][j]); for(i=0;i<row;i++){ for(j=0;j<col;j++){ while(1){ if(judge(i,j,curMax) == 1){ maxWidth = curMax; curMax++; } else break; } } } printf("%d",maxWidth*maxWidth); return 0; }
标签:break turn else highlight bre scan cpp lse 训练
原文地址:https://www.cnblogs.com/Hqx-curiosity/p/12234838.html