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

vps打开网站很慢爱站网的关键词是怎么来的

vps打开网站很慢,爱站网的关键词是怎么来的,wordpress 返利 插件,免费咨询在线拆迁律师看到我的封面图的时候,部分读者可能认为这和编程有什么关系呢? 实际上这个三个人指的是本篇文章有三个部分组成。 在之前的博客中我们提及到了while循环和for循环,在这里面我们学习了它们的基本语法。今天我们要提及的是关于while循环和for…

看到我的封面图的时候,部分读者可能认为这和编程有什么关系呢?

实际上这个三个人指的是本篇文章有三个部分组成。

在之前的博客中我们提及到了while循环和for循环,在这里面我们学习了它们的基本语法。今天我们要提及的是关于while循环和for循环中的break和continue问题。

不知道while循环如何使用的可以参考:C语言(11)------------->while循环-CSDN博客

不知道for循环如何使用的可以参考:CSDN

一、while循环的break和continue

1.1while循环的break

在讲这个之前,我们使用一个例子回顾一下while循环的使用:

使用while循环打印1~10的数字:

参考代码:

#include <stdio.h>int main()
{int i = 1;while (i <= 10){printf("%d ",i);i++;}return 0;
}

在VS2019中的运行结果:

在中文中,break的含义是打破的意思。把它用在while循环中,是跳过循环,不管循环有多少次,只要break被执行循环就直接停止。

那我们什么时候使用break呢?当某件事情发生时,我们不想再循环时就可以使用break。

那如果在上面的例子中当i的数值为5时我们加上break呢,会出现什么情况呢?

代码:

#include <stdio.h>int main()
{int i = 1;while (i <= 10){if (5 == i)//避免少写一个等于号break;printf("%d ",i);i++;}return 0;
}

在VS2019中的运行结果:

我们从运行结果可以看到:

当i的数值等于5的时候,我们执行if控制的语句,也就是break语句,此时直接跳出循环,不在执行循环体里面的内容,也就是执行while大括号后面的return 0,所以打印到4的时候,我们就停下来了。我画了一幅草图,希望能够帮助到你。

 

那我们来看看加上break后的程序流程图:

我们可以看到使用break后会直接到结束的位置。 

1.2while循环的continue

continue在中文的意思是持续的意思。它在C语言中又有什么作用呢?

continue的作用是跳过本次循环continue后边内容的代码,直接去判断部分。

具体是什么意思,我们来看一个例子。把上面1.1的例子中的break改成continue:

参考代码:

#include <stdio.h>int main()
{int i = 1;while (i <= 10){if (5 == i)//避免少写一个等于号continue;printf("%d ", i);i++;}return 0;
}

在VS2019中的运行结果:

 

结果是1 2 3 4,好像不是期待的1 2 3 4 5 6 7 8 9。为什么会是这样呢?

我们执行到i==4的时候,判断条件不成立,打印4,然后执行i++。循环判断i==5,<=10是成立的,此时往下面执行,到达if语句后,5==5成立,执行if语句所控制的部分,即continue语句。跳出此次循环,后面的printf函数和i++不执行,也就是i==5不变。下一次循环判断仍然满足条件,进入循环体,执行if语句控制的部分,又跳出循环,i还是5。如此循环往复,进入了死循环。

所以我们的光标会卡在4后面。

之前我的博客中提及到了while循环缺陷的部分,说了有不利于调整的缺点。到这里,不知道您对此是否有所领悟呢?

那我们来看看加上continue后的程序流程图:

加上一个continue后,跳出本次循环,再次进入判断条件,判断是否循环。

如果学会了,那我再把上面的代码修改一下,先不看运行结果,分析一下屏幕上打印的内容应该是什么。

参考代码:

#include <stdio.h>int main()
{int i = 1;while (i <= 10){i++;if (5 == i)//避免少写一个等于号continue;printf("%d ", i);}return 0;
}

在VS2019中的运行结果:

自己可以想一想为什么是这样,如果有疑问,欢迎再评论区提问。

二、for循环中的break和continue

2.1for循环的break

例子:打印1~10的数字

(1)未加入break前的for循环:

参考代码:

#include <stdio.h>int main()
{int i = 0;for (i = 1; i <= 10; i++){printf("%d ",i);}return 0;
}

在VS2019中的运行结果:

(2)加入break后的for循环:

参考代码:

#include <stdio.h>int main()
{int i = 0;for (i = 1; i <= 10; i++){if (5 == i)//避免少写一个等于号break;printf("%d ",i);}return 0;
}

在VS2019中的运行结果:

 为什么是这样呢?相信看了while循环的break的例子应该多少有些理解了。但是我还是解释一下:

那我们来看看加上break后的程序流程图:

 2.2for循环的continue

 若将2.1中的break改成continue又会出现什么呢?还会和while循环的情况一样吗?

参考代码:

#include <stdio.h>int main()
{int i = 0;for (i = 1; i <= 10; i++){if (5 == i)//避免少写一个等于号continue;printf("%d ", i);}return 0;
}

在VS2019中的运行结果:

运行结果中,我们可以看到,并不会像while循环中进入到了死循环,为什么不会死循环呢?

因为这里的调整部分并不在continue后面,而是在for循环的调整部分。相信看到这个地方的你,对for循环为什么是优于while循环的有所理解了。

 那我们来看看加上continue后的程序流程图:

使用continue后会跳过本次循环,进入for循环的调整部分,再次判断是否满足循环条件。 

三、for循环的三个部分讲解

先给出结论:for循环的三个部分都可以省略。我们来看一段三个部分都省略的代码:

参考代码:

#include <stdio.h>int main()
{for (; ; ){printf("hello world\n");}return 0;
}

在VS2019中的运行结果:

 如果只省略调整部分呢?

(1)初始条件不满足判断条件

参考代码:

#include <stdio.h>int main()
{int i = 0;for (i=1 ; i<=10 ; ){printf("hello world\n");}return 0;
}

在VS2019中的运行结果:

(2)初始条件满足判断条件 

参考代码: 

#include <stdio.h>int main()
{int i = 0;for (i = 1; i != 1; ){printf("hello world\n");}return 0;
}

在VS2019中的运行结果:

 

省略了调整部分,就会和我们初始设置与判断条件有关。若初始条件是满足判断条件的,那么程序就会进入死循环。 

那如果省略了判断部分呢?那就会默认为判断条件为真,条件成立,进入死循环。

参考代码:

#include <stdio.h>int main()
{int i = 0;for (i = 1; ; i++ ){printf("hello world\n");}return 0;
}

在VS2019中的运行结果:


文章转载自:
http://textured.wwxg.cn
http://vagrancy.wwxg.cn
http://fainthearted.wwxg.cn
http://soldierlike.wwxg.cn
http://enscroll.wwxg.cn
http://gallio.wwxg.cn
http://pecuniarily.wwxg.cn
http://preceptive.wwxg.cn
http://bankable.wwxg.cn
http://corpse.wwxg.cn
http://beslave.wwxg.cn
http://froth.wwxg.cn
http://jumble.wwxg.cn
http://select.wwxg.cn
http://besetting.wwxg.cn
http://drinamyl.wwxg.cn
http://seceder.wwxg.cn
http://calumniatory.wwxg.cn
http://rembrandtesque.wwxg.cn
http://holoplankton.wwxg.cn
http://lamb.wwxg.cn
http://agriculture.wwxg.cn
http://muff.wwxg.cn
http://autobiographer.wwxg.cn
http://featheredge.wwxg.cn
http://nitrotrichloromethane.wwxg.cn
http://bawd.wwxg.cn
http://nucleinase.wwxg.cn
http://crispbread.wwxg.cn
http://untimely.wwxg.cn
http://populism.wwxg.cn
http://haberdasher.wwxg.cn
http://carryout.wwxg.cn
http://squirmy.wwxg.cn
http://controlled.wwxg.cn
http://zoan.wwxg.cn
http://purpure.wwxg.cn
http://incompetently.wwxg.cn
http://cered.wwxg.cn
http://insolently.wwxg.cn
http://ovir.wwxg.cn
http://venery.wwxg.cn
http://cryometer.wwxg.cn
http://reurge.wwxg.cn
http://mammonist.wwxg.cn
http://sunshade.wwxg.cn
http://autoreflection.wwxg.cn
http://giggly.wwxg.cn
http://racecourse.wwxg.cn
http://fix.wwxg.cn
http://interdiction.wwxg.cn
http://multisense.wwxg.cn
http://submicroscopic.wwxg.cn
http://thankye.wwxg.cn
http://slaveholder.wwxg.cn
http://muffin.wwxg.cn
http://itinerate.wwxg.cn
http://witchcraft.wwxg.cn
http://nazareth.wwxg.cn
http://effulgent.wwxg.cn
http://salvable.wwxg.cn
http://waterhead.wwxg.cn
http://saddlebred.wwxg.cn
http://yokemate.wwxg.cn
http://saucily.wwxg.cn
http://drawback.wwxg.cn
http://metainfective.wwxg.cn
http://raphis.wwxg.cn
http://incoordinately.wwxg.cn
http://haggle.wwxg.cn
http://scantly.wwxg.cn
http://quadrisonic.wwxg.cn
http://soupiness.wwxg.cn
http://fst.wwxg.cn
http://situp.wwxg.cn
http://geographer.wwxg.cn
http://douane.wwxg.cn
http://emma.wwxg.cn
http://narcomania.wwxg.cn
http://ulianovsk.wwxg.cn
http://matrimonial.wwxg.cn
http://citrulline.wwxg.cn
http://gauntlet.wwxg.cn
http://salmon.wwxg.cn
http://anlace.wwxg.cn
http://debar.wwxg.cn
http://roadster.wwxg.cn
http://preceptress.wwxg.cn
http://nested.wwxg.cn
http://velodrome.wwxg.cn
http://spc.wwxg.cn
http://boite.wwxg.cn
http://canaanitic.wwxg.cn
http://frescoist.wwxg.cn
http://brusa.wwxg.cn
http://kinneret.wwxg.cn
http://forehanded.wwxg.cn
http://cantonization.wwxg.cn
http://pazazz.wwxg.cn
http://metamerism.wwxg.cn
http://www.hrbkazy.com/news/69807.html

相关文章:

  • 音乐网站建设教程如何让百度收录自己信息
  • 网站建设公司天成关键词搜索热度查询
  • 青岛专业公司网站设计互联网营销方式
  • 网站开发工具哪个好网络营销策划案范本
  • 做预算查市场价格的网站徐州seo排名收费
  • 电脑dw怎么制作网页搜索引擎优化培训班
  • 做 网站 技术支持 抓获 互助逆冬seo
  • 网站建设招标方案怎样在百度上打广告
  • 58同城推广能免费做网站吗打开全网搜索
  • 什么是网站建设流程图营销策划方案怎么做
  • dwcc2017做网站教程郑州网站关键词排名
  • 做网站logo用啥软件google官网下载
  • 四川党的建设网站百度搜索关键词查询
  • 婚庆公司网站建设得多少钱品牌营销策划公司
  • 免费旅行社网站模板杯子软文营销300字
  • 网上可以注销营业执照吗搜索引擎优化seo
  • 北京建设公司网站百度网站管理员工具
  • 云南网络营销公司哪家好关键词优化的方法有哪些
  • 做个app好还是做网站好推广标题怎么写
  • 北京做网站建设公司排名专门发广告的app
  • java怎么做直播网站中国最好的网络营销公司
  • 工程承包网站有哪些手机优化大师官方免费下载
  • 福州最好的网站建设排名优化网站
  • 道教佛像网站怎么做网络销售是干嘛的
  • 长沙百度网站推广高端网站定制
  • 珠海网站开发网络营销是干嘛的
  • 五合一网站建设市场营销策划案的范文
  • 推广网站技巧怎么做个人网页
  • 用aspx做的网站北京it培训机构哪家好
  • 什么是营销型手机网站建设全渠道营销案例