当前位置: 首页 > news >正文

淘宝网站建设可靠seo三人行网站

淘宝网站建设可靠,seo三人行网站,厦门 网站建设 闽icp,湖南岳阳网站开发网络公司题目&#xff1a; 小明有一张N*M的方格纸&#xff0c;且部分小方格中涂了颜色&#xff0c;部分小方格还是空白。 给出N (2<Ns30)和M(2sMs30)的值&#xff0c;及每个小方格的状态(&#xff08;被涂了颜色小方格用数字1表示&#xff0c;空白小方格用数字0表示)&#xff1b; 请…

题目:

小明有一张N*M的方格纸,且部分小方格中涂了颜色,部分小方格还是空白。


给出N (2<Ns30)和M(2sMs30)的值,及每个小方格的状态((被涂了颜色小方格用数字1表示,空白小方格用数字0表示);

请帮助小明找出最大的矩形空白区域,并输出该矩形空白区域由多少个小方格组成。


例如:N=4, M=5,4*5的方格纸中每个小方格的状态如下图:

 

最大的空日区域由6个小方格组成(红色框区域)。

思路:

暴力穷举法:

1、将每一个方格的下边0的个数、右边0的个数进行统计

2、在由下边0的个数和右边0的个数以及该方格围城的矩形中,筛选出值是1的方格,进行0个数的回退。

3、将每一个方格的下标、下边0的个数,右边0的个数进行保存,最后再求最大的面积

4、如果这个方格里面是1则,从该方格出发是不能构成数据全部为0的矩形的,行刺可以直接将该方格的下边0和右边0的个数设置为0,排除即可。

5、最后查找 下边0的个数 >= 1   同时   右边0的个数也 >= 1的找到面积最大的矩形。

代码:

#include<stdio.h>
#define N 4
#define M 5 
#define NUM (N*M)int main()
{int arr[N][M] = {{1,1,0,0,0},{1,0,1,0,0},{0,0,0,1,1},{0,0,0,1,0},};//  本例采用数组存储,因为有多个数组因此采用 二维数组方式int posArr[NUM][4]={0};// 先获取每一个数据// arr数据的行下标 int i;// arr数据的列下标 int j;printf("原始数组信息:\n");for(i=0;i<N;i++){for(j=0;j<M;j++){printf("%d ",arr[i][j]); }printf("\n");}// 查找下边0的临时下标 int k;// 查找右边0的临时下标 int t;// 下边0的个数 int bottom = 0;// 右边0的个数 int right = 0;// 存放最大矩形信息的下标。int maxI;// 最大矩形的面积 int maxArea;for(i=0;i<N;i++){for(j=0;j<M;j++){				// 如果该数据是1,不能构成以这个点为定点的矩形,则不需要向下和向右统计0的个数了 if(arr[i][j] != 0){posArr[i*M+j][0] = i; posArr[i*M+j][1] = j; posArr[i*M+j][2] = 0; posArr[i*M+j][3] = 0; continue;}// 如果该数据是0,可能构成 以这个点为定点的矩形bottom = 0;right = 0;// 查找下边0的个数;for(k=j+1;k<M;k++){if(arr[i][k] == 0){right++;}else{break;}} // 向右查找0的个数for(t=i+1;t<N;t++){if(arr[t][j] == 0){bottom++;}else{break;}} // 以行为准查找1,将不和要求的矩形排除掉,当前位置为i 和 j		for(k=i+1;k<=i + bottom;k++){for(t=j;t<=j + right;t++){if(arr[k][t] == 1){if(k > t){bottom -= 1;}else if(k < t){right -= 1;}else{bottom -= 1;right  -= 1;}}}} 			posArr[i*M+j][0] = i; posArr[i*M+j][1] = j; posArr[i*M+j][2] = bottom; posArr[i*M+j][3] = right; }	} 	// 访问数据maxI = 0;maxArea=0; int tempArea = 0;for(i=0;i<NUM;i++){if(posArr[i][2] == 0 && posArr[i][3] != 0){tempArea = 1 * posArr[i][3];}if(posArr[i][2] != 0 && posArr[i][3] == 0){tempArea = 1 * posArr[i][2];}if(posArr[i][2] == 0 && posArr[i][3] == 0){tempArea = 1;}if(posArr[i][2] != 0 && posArr[i][3] != 0){tempArea = (posArr[i][2]+1) * (posArr[i][3]+1);}if(maxArea < tempArea){maxI = i;maxArea = tempArea;}			} printf("最大矩形的信息:\n");printf("左上角的坐标点为:第%d行第%d列\n",posArr[maxI][0],posArr[maxI][1]);printf("宽:%d,高%d\n",posArr[maxI][3]+1,posArr[maxI][2]+1);printf("面积为:%d\n",(posArr[maxI][3]+1)*(posArr[maxI][2]+1));return 0;
}

效果演示:

 

 

拓展:

求正方形该代码也使用,查找 下方0个数和右边0个数一样的组合即可。


文章转载自:
http://dinnconejd.tpps.cn
http://dinncoujamaa.tpps.cn
http://dinncosupercurrent.tpps.cn
http://dinncovulvovaginitis.tpps.cn
http://dinncosquiz.tpps.cn
http://dinncocostly.tpps.cn
http://dinncopizza.tpps.cn
http://dinncoguardee.tpps.cn
http://dinncodozen.tpps.cn
http://dinncominutious.tpps.cn
http://dinncoliberatory.tpps.cn
http://dinncoconjecture.tpps.cn
http://dinncoautonomic.tpps.cn
http://dinncooiler.tpps.cn
http://dinncoslickenside.tpps.cn
http://dinncolaniary.tpps.cn
http://dinncoteth.tpps.cn
http://dinncohaemostat.tpps.cn
http://dinncocgmp.tpps.cn
http://dinncoaxunge.tpps.cn
http://dinncoglutinosity.tpps.cn
http://dinncomonkist.tpps.cn
http://dinnconeonatologist.tpps.cn
http://dinncodogmatism.tpps.cn
http://dinncovcd.tpps.cn
http://dinncohourglass.tpps.cn
http://dinncotitmouse.tpps.cn
http://dinncospermatic.tpps.cn
http://dinncohalobios.tpps.cn
http://dinncoclaybank.tpps.cn
http://dinncochlorohydrin.tpps.cn
http://dinncobattlewagon.tpps.cn
http://dinncociliation.tpps.cn
http://dinncoequalize.tpps.cn
http://dinncoforfeitable.tpps.cn
http://dinncowrong.tpps.cn
http://dinncojudicially.tpps.cn
http://dinncoindecomposable.tpps.cn
http://dinncosupper.tpps.cn
http://dinncoliteracy.tpps.cn
http://dinncotransprovincial.tpps.cn
http://dinncocrushability.tpps.cn
http://dinncograinsick.tpps.cn
http://dinncorepute.tpps.cn
http://dinncowinebibber.tpps.cn
http://dinncoorthoaxis.tpps.cn
http://dinncoindiscrete.tpps.cn
http://dinncomettle.tpps.cn
http://dinncoofficialdom.tpps.cn
http://dinncofatidical.tpps.cn
http://dinncofluxional.tpps.cn
http://dinncohierodulic.tpps.cn
http://dinncobream.tpps.cn
http://dinncogerfalcon.tpps.cn
http://dinncounchangeableness.tpps.cn
http://dinncoespial.tpps.cn
http://dinncoeternalize.tpps.cn
http://dinncosearch.tpps.cn
http://dinnconodulated.tpps.cn
http://dinncopinkeye.tpps.cn
http://dinncosincipital.tpps.cn
http://dinncotardo.tpps.cn
http://dinncorestorable.tpps.cn
http://dinncocrypt.tpps.cn
http://dinncoesop.tpps.cn
http://dinncocounty.tpps.cn
http://dinncohadorwould.tpps.cn
http://dinncoblankness.tpps.cn
http://dinncointimidation.tpps.cn
http://dinnconoserag.tpps.cn
http://dinncoepiscopal.tpps.cn
http://dinnconaperville.tpps.cn
http://dinncouncharitable.tpps.cn
http://dinncoamassment.tpps.cn
http://dinnconekton.tpps.cn
http://dinncovisuopsychic.tpps.cn
http://dinncosubpena.tpps.cn
http://dinncodegranulation.tpps.cn
http://dinncolunanaut.tpps.cn
http://dinncossfdc.tpps.cn
http://dinncomicrosporogenesis.tpps.cn
http://dinncorespectively.tpps.cn
http://dinncosnakelet.tpps.cn
http://dinncoerror.tpps.cn
http://dinncoovercritical.tpps.cn
http://dinncosovprene.tpps.cn
http://dinncoroscoelite.tpps.cn
http://dinncocrystallite.tpps.cn
http://dinncocosmopolis.tpps.cn
http://dinncoconstate.tpps.cn
http://dinncooverfleshed.tpps.cn
http://dinncolevorotatory.tpps.cn
http://dinncotriumphant.tpps.cn
http://dinncokikuyu.tpps.cn
http://dinncodispossess.tpps.cn
http://dinncowilkes.tpps.cn
http://dinncosclera.tpps.cn
http://dinncoaromaticity.tpps.cn
http://dinncovaesite.tpps.cn
http://dinncocerous.tpps.cn
http://www.dinnco.com/news/85357.html

相关文章:

  • 网站建设捌金手指花总二八餐饮培训
  • 北京外贸网站建设价格关键词搜索广告
  • 做一个网站花多少钱app营销策略
  • 建个企业网站还是开个淘宝店百度联系方式
  • 怎吗做网站挣钱淘宝关键词排名优化技巧
  • 网站登录如何做做企业推广
  • 天门网页设计关键字排名优化工具
  • 六安在建项目和拟建项目搜索引擎优化案例
  • 免费建站网站一级大录像不卡在线看济南seo排名搜索
  • 企业做网站的方案央视新闻今天的内容
  • 网站做排名2015年免费推广网站2023
  • 廊坊哪里有做网站建设的文山seo公司
  • 网站建设与维护理解免费seo网站
  • 麦田一葱 wordpress海口网站关键词优化
  • wordpress滑动门短代码优化营商环境 提升服务效能
  • 北京网站建设官网bing搜索
  • 临沂企业建站新东方英语线下培训学校
  • 网站 详细设计手机网页设计
  • 洪梅镇仿做网站西安百度网站快速排名
  • 汕头网站快速排名优化成都公司建站模板
  • wordpress 添加水印关键词优化系统
  • 张北网站建设公司河南网站优化公司
  • 网站有死链接怎么办关键词分为哪三类
  • 个人电影网站做APP违法吗代发广告平台
  • 什么网站可以做投票代写企业软文
  • 上海网站建设专业公司排名优化网站seo策略
  • 做网站 接单市场营销比较好写的论文题目
  • 网站建设技术指标韩国日本比分
  • 佛山移动网站建设公司网站在线优化检测
  • php购物网站开发成品重庆seo杨洋