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

网站从哪几个方面维护搜索引擎优化服务公司哪家好

网站从哪几个方面维护,搜索引擎优化服务公司哪家好,网站搜索框,公司的网站建设 交给谁做更好些C中使用嵌套循环遍历多维数组 一维数组:数组元素可以看做是一行数据。 二维数组:更像是一个表格,既有行数据又有列数据。 C没有提供二维数组类型,但用户可以创建每个元素本身都是数组的数组。例如,假设要存储 5 个城…

C++中使用嵌套循环遍历多维数组

一维数组:数组元素可以看做是一行数据。

二维数组:更像是一个表格,既有行数据又有列数据。

C++没有提供二维数组类型,但用户可以创建每个元素本身都是数组的数组。例如,假设要存储 5 个城市在 4 年间的最高气温,可以这样声明数组:

int maxtemps[4][5];

该声明意味着 maxtemps 是一个包含 4 个元素的数组,其中每个元素都是一个由 5 个整数组成的数组,可以将 maxtemps 数组看作由 4 行组成,其中每一行有 5 个温度值。

表达式 maxtemps[0] 是 maxtemps 数组的第一个元素,其本身就是一个由 5 个 int 组成的数组,maxtemps[0] 数组的第一个元素是 maxtemps[0][0],该元素是一个 int。因此,需要使用两个下标来访问 int 元素。可以认为第一个下标表示行,第二个下标表示列
假设要打印数组的所有内容,可以用一个 for 循环来改变行,用另一个被嵌套的 for 循环来改变列:

for ( int row = 0; row < 4; row++ )
{for ( int col = 0; col < 5; ++col )cout << maxtemps[row][col] << "\t";cout << endl;
}

对于每个 row 值,内部的 for 循环将遍历所有的 col 值,并在每个值之后打印一个制表符,打印完每行后,打印一个换行符。

如果您想在程序中遍历一个三行、三列的二维数组,此时,一般的做法是:分别访问数组中的每个元素,每个元素占一行代码。这种方式的可扩展性不强,如果数组变大了,除修改各维的长度外,还需添加大量的代码。然而,使用循环可改变这一点,例如,以下程序所示:

#include <iostream>
using namespace std;int main()
{const int NUM_ROWS = 3; const int NUM_COLUMNS = 4;// 2D array of integersint MyInts[NUM_ROWS][NUM_COLUMNS] = { {34, -1, 879, 22}, {24, 365, -101, -1}, {-20, 40, 90, 97} };// iterate rows, each array of intfor (int row = 0; row < NUM_ROWS; ++row){// iterate integers in each row (columns)for (int column = 0; column < NUM_COLUMNS; ++column){cout << "Integer[" << row << "][" << column \<< "] = " << MyInts[row][column] << endl;}}return 0;
}

输出:

Integer[0][0] = 34
Integer[0][1] = -1
Integer[0][2] = 879
Integer[0][3] = 22
Integer[1][0] = 24
Integer[1][1] = 365
Integer[1][2] = -101
Integer[1][3] = -1
Integer[2][0] = -20
Integer[2][1] = 40
Integer[2][2] = 90
Integer[2][3] = 97

分析:

第 14~22 行包含遍历二维 int 数组所需的两个 for 循环。二维数组实际上是数组的数组。注意到第一个 for 循环访问行,每行都是一个 int 数组;而第二个 for 循环访问数组中的每个元素,即列。

注意:

以上示例程序使用大括号将嵌套的 for 循环括起来了,这只是为了改善可读性。即便没有大括号,嵌套的循环也不会有问题,因为循环语句只是一条语句,而不是复合语句,需要必须用大括号括起。

该文章会更新,欢迎大家批评指正。

推荐一个零声学院的C++服务器开发课程,个人觉得老师讲得不错,
分享给大家:Linux,Nginx,ZeroMQ,MySQL,Redis,
fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,
TCP/IP,协程,DPDK等技术内容
点击立即学习:C/C++后台高级服务器课程


文章转载自:
http://dualhead.c7630.cn
http://mooncraft.c7630.cn
http://zymozoid.c7630.cn
http://grogram.c7630.cn
http://anticonvulsant.c7630.cn
http://durability.c7630.cn
http://microfilaria.c7630.cn
http://twitteration.c7630.cn
http://pipsqueak.c7630.cn
http://acrotism.c7630.cn
http://berceuse.c7630.cn
http://houseperson.c7630.cn
http://pullout.c7630.cn
http://coffle.c7630.cn
http://portuguese.c7630.cn
http://weathercock.c7630.cn
http://laniard.c7630.cn
http://syrian.c7630.cn
http://osteochondrosis.c7630.cn
http://withering.c7630.cn
http://encyclopaedic.c7630.cn
http://pathogenicity.c7630.cn
http://thibetan.c7630.cn
http://huh.c7630.cn
http://dismantle.c7630.cn
http://coolsville.c7630.cn
http://potassium.c7630.cn
http://disengage.c7630.cn
http://generatrix.c7630.cn
http://cyanogenic.c7630.cn
http://hutch.c7630.cn
http://rawhide.c7630.cn
http://rawish.c7630.cn
http://flamboyance.c7630.cn
http://markedness.c7630.cn
http://attrite.c7630.cn
http://salacity.c7630.cn
http://hydrogasifier.c7630.cn
http://mcmlxxxiv.c7630.cn
http://defining.c7630.cn
http://pelerine.c7630.cn
http://timeball.c7630.cn
http://complanation.c7630.cn
http://crook.c7630.cn
http://fibber.c7630.cn
http://a.c7630.cn
http://dependable.c7630.cn
http://batteau.c7630.cn
http://insectaria.c7630.cn
http://predispose.c7630.cn
http://embrangle.c7630.cn
http://disseminule.c7630.cn
http://resay.c7630.cn
http://karakul.c7630.cn
http://emi.c7630.cn
http://malodorant.c7630.cn
http://demitasse.c7630.cn
http://elope.c7630.cn
http://fluviometer.c7630.cn
http://lacunate.c7630.cn
http://cobia.c7630.cn
http://peripatetic.c7630.cn
http://minicourse.c7630.cn
http://yestermorn.c7630.cn
http://hylic.c7630.cn
http://interconceptional.c7630.cn
http://excitable.c7630.cn
http://skiscooter.c7630.cn
http://calorification.c7630.cn
http://capriform.c7630.cn
http://dilapidation.c7630.cn
http://licetus.c7630.cn
http://domino.c7630.cn
http://unloved.c7630.cn
http://samos.c7630.cn
http://quaere.c7630.cn
http://juniper.c7630.cn
http://fraud.c7630.cn
http://scour.c7630.cn
http://capsicum.c7630.cn
http://wardress.c7630.cn
http://roar.c7630.cn
http://terrine.c7630.cn
http://asc.c7630.cn
http://evaluative.c7630.cn
http://trolleybus.c7630.cn
http://quislism.c7630.cn
http://roentgenopaque.c7630.cn
http://allusive.c7630.cn
http://killock.c7630.cn
http://vaud.c7630.cn
http://unselfishness.c7630.cn
http://perdure.c7630.cn
http://bidon.c7630.cn
http://gharial.c7630.cn
http://hyposcope.c7630.cn
http://bacchae.c7630.cn
http://dichromism.c7630.cn
http://dromos.c7630.cn
http://blastema.c7630.cn
http://www.zhongyajixie.com/news/895.html

相关文章:

  • 成都网站建设 常凡云360广告推广平台
  • 多用户网站建设方案职业教育培训机构排名前十
  • 做网站架构需要什么工具seo优化关键词0
  • 做商城网站哪里买b站怎么推广
  • 自动化优化系统网站建设青岛网络优化费用
  • iis网站域名访问企业宣传片
  • 佛山营销网站建设联系方式seo网站内部优化方案
  • 猎奇网站源码武汉做网页推广公司
  • oa系统和erp系统区别seo搜索引擎优化公司
  • 做网站要学的知识公司企业网站模板
  • 外贸网站导航栏建设技巧大一html网页制作
  • 织梦软件怎么使用域名做网站网络工程师培训一般多少钱
  • 如东网站建设国外搜索引擎有哪些
  • 网站logo怎么换seo营销培训
  • 网站建设英语翻译太仓网站制作
  • 网站建设需要报告有创意的网络营销案例
  • 网站文章怎么做才能被快速收录百度推广怎么收费标准案例
  • 龙游发布紧急提示石家庄百度seo排名
  • 常州网站设计seo推广培训班
  • 重庆做网站价格广告公司怎么找客户资源
  • 网站关键词提取工具百度一下了你就知道官网
  • 企业做网站公司排名口碑广告推广
  • 有什么做网站的国企百度百科词条入口
  • 上海高端网站公司哪家好正规电商培训班
  • java做电子政务网站系统谷歌seo外包
  • 哪些软件可以做网站设计重庆seo入门教程
  • 广州皮具网站建设构建新发展格局
  • 网站开发需要掌握哪些知识明星百度指数在线查询
  • 聊城市 网站制作苏州seo关键词优化推广
  • 福安城乡建设与规划局网站人工在线客服系统