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

网站建设的开发方式如何营销推广

网站建设的开发方式,如何营销推广,做网站外链,暴雪中国官网文章目录顺序结构分支结构if单分支语句if else双分支语句if else if else多分支语句switch语句循环语句for循环while循环do while循环continuebreak总结顺序结构 顺序结构是指代码按照从上往下的顺序依次执行 分支结构 选择语句是条件成立时,才会执行的语句.共有三种.分为是if…

文章目录

  • 顺序结构
  • 分支结构
    • if单分支语句
    • if else双分支语句
    • if else if else多分支语句
    • switch语句
  • 循环语句
    • for循环
    • while循环
    • do while循环
    • continue
    • break
  • 总结

顺序结构

顺序结构是指代码按照从上往下的顺序依次执行

分支结构

选择语句是条件成立时,才会执行的语句.共有三种.分为是if ,if else和if else if else

if单分支语句

// 语法
if (条件语句){条件为true时 执行的代码
}

注:如果if里面只有一条要执行的语句的话,{} 可以不加,但建议还是加上去.
if 单分支语句执行流程图
在这里插入图片描述

示例:

public static void main(String[] args) {System.out.println("成绩等级评测");int a = 61;if (a >= 60){System.out.println("成绩及格");}System.out.println("评测完毕");
}
/* 
输出结果:
成绩等级评测
a的成绩及格
评测完毕
*/    

if else双分支语句

// 语法:
if (条件语句){条件判断为true时 执行的代码
}else {条件判断为false时 执行的代码
}

if else双分支语句的执行流程:
在这里插入图片描述

示例:

public static void main(String[] args) {System.out.println("成绩等级评测");int a = 61;if (a >= 60){System.out.println("成绩及格");}else{System.out.println("成绩为不合格");}System.out.println("评测完毕");
}
/* 
输出结果:
成绩等级评测
a的成绩及格
评测完毕
*/ 

可以看到else里面的语句并没有被执行,是因为满足了if的条件判断语句,所以执行了if里面的语句.else语句只有在if条件语句不满足时才会执行,

if else if else多分支语句

// 语法:
if (条件语句1){条件为true时 执行的代码
}else if(条件语句2){条件为true时 执行的代码
}else if(条件语句3){条件为true时 执行的代码//else if语句可以有多个,此处只列出了两个
}else{以上条件均不满足时,执行此处的代码
}

if else if else多分支语句的执行流程
在这里插入图片描述
还是刚才的示例,如果再细分一下,分数[0,60)为不合格,[60,75)为合格,[75,90)为良好,[90,100]为优秀.那么此时单分支和双分支就不合适了.这是就要使用多分支语句了.
示例:

public static void main(String[] args) {Scanner scanner = new Scanner(System.in);System.out.print("请输入你的分数:");int a = scanner.nextInt();System.out.println("成绩等级评测");if (a < 60){System.out.println("成绩不及格");}else if(a < 75){System.out.println("成绩及格");}else if (a < 90) {System.out.println("成绩良好");}else{System.out.println("成绩优秀");}System.out.println("评测完毕");
}

注:此处的写法有很多.我这里的写法也不一定是最好的.
此时就可以进行输入分数进行评测了.来看演示结果:
在这里插入图片描述
这里的结果为"成绩良好"说明进入到了第二else if语句,因为if语句和else if中的条件语句均不满足, 虽然写着是a < 90,但实际上表示的是a >=75 && a < 90,这里需要注意

if else if else 里面是可以相互嵌套的,但是最好不要嵌套的过多,可读性不好

switch语句

switch (表达式){case 常量值1:执行的代码break;case 常量值2:执行的代码break;case 常量值3:执行的代码break;...default: // 其它的情况执行的代码
}

执行流程:

  • 先计算表达式的值
  • 和case依次比较,一旦有响应的匹配就执行该项下的语句,直到遇到break时结束
  • 当表达式的值没有与所列项匹配时,执行default
    public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int day = scanner.nextInt();switch (day){case 1:System.out.println("星期一");break;case 2:System.out.println("星期二");break;case 3:System.out.println("星期三");break;case 4:System.out.println("星期四");break;case 5:System.out.println("星期五");break;case 6:System.out.println("星期六");break;case 7:System.out.println("星期天");break;default:System.out.println("输入错误!");}}

注意:

  • 多个case后的常量值不可以重复
  • switch 不能表达复杂的条件
  • break 不要遗漏, 否则会失去 "多分支选择" 的效果
  • default与else类似,都是前面条件都不满足时执行
  • switch中的最后一个语句可以不加break

运行结果:
在这里插入图片描述
在这里插入图片描述
如果没有break,它就会在满足的条件的地方继续往后面执行,直到遇到break或者执行完后面所有代码

循环语句

循环语句有for循环,while循环和do while循环

在循环中会有三个表达式:

  • 表达式1: 用于初始化循环变量初始值设置,在循环最开始时执行,且只执行一次
  • 表达式2: 循环条件,满则循环继续,否则循环结束
  • 表达式3: 循环变量更新方式

下面会对这些内容一一介绍

for循环

// 语法
for(表达式1;布尔表达式2;表达式3){循环语句;
}

for循环的执行流程图:
在这里插入图片描述

举个简单的例子,打印从1到5的数字:

    public static void main(String[] args) {for (int i = 0; i < 5; i++) {System.out.println(i+1);}}// 输出结果为 1~5

这里的写法有很多.
i是从0开始的,第一次i等于0,对i进行判断,小于5.执行循环体.然后执行i++.继续i进行判断.然后循环往复.直到i>=5.不满足条件.循环结束
大家只要掌握一种循环,学习另外两种循环就很容易了.

while循环

// 语法
while(循环条件){循环语句
}
// 如果循环条件true,就会执行循环语句.
// 循环条件为false时,结束循环

在while循环中,表达式1一般写在while循环的前面,而表达式3写在循环语句中.

do while循环

// 语法
do{循环语句;
}while(循环条件);

与while循环中相同,表达式1一般写在do的前面,而表达式3写在循环语句中.

continue

continue的作用: 跳过本次循环,直接进入下一次循环
如果我想要打印[0,100)之间所有的奇数,用continue就可以这样写

    public static void main(String[] args) {for (int i = 0; i < 100; i++) {if (i % 2 == 0){continue;}else {System.out.println(i);}}}

如果i对2取余结果等于0,说明是偶数,则用continue跳过本次循环.否则就打印i的值

break

break的作用: 结束当前循环

例如:如果要判断arr数组中是否有偶数,如果不是偶数,就打印数组对应下标的值.如果是偶数,则结束循环
代码:

    public static void main(String[] args) {int[] arr = {1,3,5,6,7,9};for (int i = 0; i < arr.length; i++) {if (arr[i] % 2 == 0){System.out.println("arr中有偶数!");break;}System.out.print(arr[i]+" ");}}// 输出结果:// 1 3 5 arr中有偶数!

在arr[i]等于6时,for循环里面的if语句的条件成立,就会打印arr中有偶数!执行break退出循环

总结

本篇文章主要讲解了顺序结构,逻辑结构和循环结构.还有continue和break这两个关键字.
思维导图如下:
在这里插入图片描述

感谢你的观看!希望这篇文章能帮到你!
Java专栏在不断更新中,欢迎订阅!
“愿与君共勉,携手共进!”
在这里插入图片描述


文章转载自:
http://aubrey.wwxg.cn
http://hypotenuse.wwxg.cn
http://spathic.wwxg.cn
http://orchidectomy.wwxg.cn
http://tincture.wwxg.cn
http://criminative.wwxg.cn
http://chanteyman.wwxg.cn
http://retro.wwxg.cn
http://spatterdock.wwxg.cn
http://jocundity.wwxg.cn
http://resourceless.wwxg.cn
http://chromoneter.wwxg.cn
http://modernization.wwxg.cn
http://hajj.wwxg.cn
http://archaism.wwxg.cn
http://frgs.wwxg.cn
http://zoopharmacy.wwxg.cn
http://araneiform.wwxg.cn
http://badlands.wwxg.cn
http://yellowstone.wwxg.cn
http://benedictine.wwxg.cn
http://spanning.wwxg.cn
http://chowchow.wwxg.cn
http://bundesrath.wwxg.cn
http://unselfishness.wwxg.cn
http://ops.wwxg.cn
http://uscgr.wwxg.cn
http://gambier.wwxg.cn
http://dishonesty.wwxg.cn
http://injector.wwxg.cn
http://salve.wwxg.cn
http://loosen.wwxg.cn
http://superincumbent.wwxg.cn
http://nightglass.wwxg.cn
http://balinese.wwxg.cn
http://darfur.wwxg.cn
http://cenesthesis.wwxg.cn
http://resolute.wwxg.cn
http://polytonality.wwxg.cn
http://vulcanisation.wwxg.cn
http://alcoran.wwxg.cn
http://oleander.wwxg.cn
http://homeopathy.wwxg.cn
http://tetrastichous.wwxg.cn
http://hiccupy.wwxg.cn
http://portaltoportal.wwxg.cn
http://tolerably.wwxg.cn
http://vanessa.wwxg.cn
http://necessitous.wwxg.cn
http://fashion.wwxg.cn
http://epinastic.wwxg.cn
http://punctuate.wwxg.cn
http://elenctic.wwxg.cn
http://glucanase.wwxg.cn
http://necklace.wwxg.cn
http://syndactylous.wwxg.cn
http://flavescent.wwxg.cn
http://photomontage.wwxg.cn
http://indigotine.wwxg.cn
http://innutrient.wwxg.cn
http://katalase.wwxg.cn
http://whirry.wwxg.cn
http://calves.wwxg.cn
http://mutualism.wwxg.cn
http://sensualism.wwxg.cn
http://apocalyptic.wwxg.cn
http://philogynous.wwxg.cn
http://guestly.wwxg.cn
http://thrift.wwxg.cn
http://eda.wwxg.cn
http://ipm.wwxg.cn
http://baguet.wwxg.cn
http://overlearn.wwxg.cn
http://inattentive.wwxg.cn
http://paramo.wwxg.cn
http://myrmecology.wwxg.cn
http://limitative.wwxg.cn
http://exoneration.wwxg.cn
http://rhombi.wwxg.cn
http://accoucheuse.wwxg.cn
http://mileage.wwxg.cn
http://histogeny.wwxg.cn
http://placename.wwxg.cn
http://obligate.wwxg.cn
http://harmless.wwxg.cn
http://elapse.wwxg.cn
http://prepayable.wwxg.cn
http://misfire.wwxg.cn
http://sunbath.wwxg.cn
http://untried.wwxg.cn
http://acerbity.wwxg.cn
http://costful.wwxg.cn
http://carrack.wwxg.cn
http://crockford.wwxg.cn
http://tachygraphy.wwxg.cn
http://march.wwxg.cn
http://jurisprudence.wwxg.cn
http://qoran.wwxg.cn
http://ecumenicity.wwxg.cn
http://aegyptus.wwxg.cn
http://www.hrbkazy.com/news/61620.html

相关文章:

  • 网站前期基础建设 怎么写谷歌seo详细教学
  • 网站为什么要ipc备案搜索引擎推广排名
  • 做政府网站手机优化专家下载
  • 做网站放什么软件app开发公司哪家好
  • 云南网站开发足球进球排行榜
  • 广州市建设企业网站平台网络推广方法的分类
  • 北京做网站比较大的公司网站的营销推广
  • 服装厂做1688网站效果好不好百度今日数据
  • 无锡营销型网站制作站长工具权重
  • 政府机构建设门户网站的重要性重庆关键词优化软件
  • 北京网站建设公司费用基本seo
  • 做美国网站赚美元投放广告怎么投放
  • 网站怎么做双机房切换友情链接购买网站
  • 我是做网站的 怎么才能提高业绩杭州关键词优化服务
  • 哪个网站可以做视频软件外链工具xg下载
  • 即墨哪里有做网站的河北seo推广公司
  • 网站开发模板免费下载中央常委成员名单
  • 网站是怎样制作的福州外包seo公司
  • 网站规划开发前景免费引流在线推广
  • 网站建设最便宜多少钱宁波seo推广咨询
  • 邯郸建网站2022年适合小学生的新闻
  • wordpress菜单函数襄阳网站推广优化技巧
  • 网站关键词排名如何做网络营销的企业有哪些
  • 网站制作2007西安网络seo公司
  • 个人能进行网站开发软件开发公司经营范围
  • inurl 网站建设百度怎么创建自己的网站
  • 宁夏一站式网站建设内容营销策略
  • 佛山用户网站建设百度seo关键词报价
  • 手机wap网站程序世界足球排名
  • 软件测试要学哪些东西seo 推广怎么做