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

网站建提高seo排名

网站建,提高seo排名,定州网站建设公司,小网站模板下载地址目录 do...while()循环 do语句的语法 do语句的特点 do while循环中的break和continue 练习 goto语句 do...while()循环 do语句的语法 do 循环语句; while(表达式); do语句的特点 循环至少执行一次,使用的场景有限,所以不是经常使用。 #inc…

目录

do...while()循环

do语句的语法

 do语句的特点

do while循环中的break和continue

练习

goto语句

do...while()循环

do语句的语法

do
        循环语句;
while(表达式);

 do语句的特点

循环至少执行一次,使用的场景有限,所以不是经常使用。

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

do while循环中的break和continue

int main()
{int i = 0;do{if (i == 5)break;printf("%d ",i);i++;} while (i <= 10);return 0;
}
int main()
{int i = 0;do{if (i == 5)continue;printf("%d ",i);i++;} while (i <= 10);return 0;
}

do while循环中break和continue和在while循环中一模一样。

break都是用于终止循环,continue是跳过本次循环后边的代码,直接去判断部分。

练习

1. 计算 n的阶乘。

#include<stdio.h>
int main()
{int n = 0;scanf("%d",&n);int i = 0;int ret = 1;//得到1-n的数字,累乘for (i = 1; i <= n; i++){ret *= i;}printf("%d\n",ret);return 0;
}

.2.计算 1!+2!+3!+……+10!

效率太低,循环次数多

#include<stdio.h>
int main()
{int n = 0;int i = 0;int ret = 1;int sum = 0;//让n变起来,从1-10for (n = 1; n <= 10; n++){//得到1-n的数字,累乘for (i = 1; i <= n; i++){ret *= i;}sum += ret;ret = 1;}printf("%d\n",sum);return 0;
}

对上述代码改进,提升效率 ↓

#include<stdio.h>
int main()
{int n = 0;int i = 0;int ret = 1;int sum = 0;//让n变起来,从1-10for (n = 1; n <= 10; n++){ret *= n;//直接用上次得到的结果乘新的nsum += ret;}printf("%d\n", sum);return 0;
}

3. 在一个有序数组中查找具体的某个数字n。

此题用到了二分查找折半查找

这种方法效率很高,但条件苛刻,需要数组有序。

思路:

#include <stdio.h>
int main()
{int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };int k = 0;scanf("%d",&k);int sz = sizeof(arr) / sizeof(arr[0]);int left = 0;int right = sz - 1;int flag = 0;while (left <= right){int mid = (left + right) / 2;if (arr[mid] < k)left = mid + 1;//右下标不变else if (arr[mid] > k)right = mid - 1;//左下标不变else{printf("找到了,下标是%d\n", mid);flag = 1;break;}}if (flag == 0){printf("找不到了\n");}return 0;
}

4. 编写代码,演示多个字符从两端移动,向中间汇聚。

#include<stdio.h>
#include <windows.h>
int main()
{char arr1[] = "**********************";char arr2[] = "welcome to bit!!!!!!!!";int sz = sizeof(arr2) / sizeof(arr2[0]);int left = 0;int right = sz - 2;//减去/0,求出的是下标// int right = strlen(arr2)-1;//包含string.hwhile (left <= right){arr1[left] = arr2[left];arr1[right] = arr2[right];left++;right--;printf("%s\n",arr1);Sleep(500);//休眠0.5s,需要包含<windows.h>system("cls");//清空屏幕}printf("%s",arr2);return 0;
}

5. 编写代码实现,模拟用户登录情景,并且只能登录三次。(只允许输入三次密码,如果密码正确则提示登录成,如果三次均输入错误,则退出程序。

补充:比较字符串时,不能直接用 == 比较,strcmp函数是比较字符串的大小的,头文件是string.h

          如果>,返回 >0

          如果==,返回0

          如果< ,返回<0

#include <stdio.h>
#include <string.h>
int main()
{int i = 0;for (i = 0; i < 3; i++){char password[20] = { 0 };scanf("%s", password);if (strcmp(password, "123456") == 0){printf("登陆成功\n");break;}else{printf("密码错误\n");}if (i == 3){printf("三次密码错误,退出程序\n");}}return 0;
}

goto语句

C语言中提供了可以随意滥用的 goto语句和标记跳转的标号。
从理论上 goto语句是没有必要的,实践中没有goto语句也可以很容易的写出代码。
但是某些场合下goto语句还是用得着的,最常见的用法就是终止程序在某些深度嵌套的结构的处理过程

goto语言真正适合的场景如下:

for(...)
        for(...)
        {
                for(...)
                {
                        if(disaster)
                        goto error;
                }
        }

error:
        if(disaster)
        // 处理错误情况

下面是使用goto语句的一个例子,然后使用循环的实现方式替换goto语句:

#include <stdio.h>
int main()
{char input[10] = { 0 };system("shutdown -s -t 60");
again:printf("电脑将在1分钟内关机,如果输入我是猪,就取消关机\n");scanf("%s",input);if (strcmp(input, "我是猪") == 0){system("shutdown -a");printf("你很配合,已取消关机\n");}else{goto again;}return 0;
}

而如果不使用goto语句,则可以使用循环:

#include <stdio.h>
int main()
{char input[10] = { 0 };system("shutdown -s -t 60");while (1){printf("电脑将在1分钟内关机,如果输入我是猪,就取消关机\n");scanf("%s", input);if (strcmp(input, "我是猪") == 0){system("shutdown -a");printf("你很配合,已取消关机\n");break;}}return 0;
}


文章转载自:
http://dinncopartially.bpmz.cn
http://dinnconeocortex.bpmz.cn
http://dinncorobur.bpmz.cn
http://dinncoheiress.bpmz.cn
http://dinncocrested.bpmz.cn
http://dinncoireland.bpmz.cn
http://dinncoswitchyard.bpmz.cn
http://dinncoapoise.bpmz.cn
http://dinncoalpeen.bpmz.cn
http://dinncodigamous.bpmz.cn
http://dinncowashhouse.bpmz.cn
http://dinncoquirt.bpmz.cn
http://dinncoendoscopy.bpmz.cn
http://dinncodefacto.bpmz.cn
http://dinncotrichloroethylene.bpmz.cn
http://dinncobelting.bpmz.cn
http://dinncoreincorporate.bpmz.cn
http://dinncochestnut.bpmz.cn
http://dinncoaustral.bpmz.cn
http://dinncohairif.bpmz.cn
http://dinncosulphatise.bpmz.cn
http://dinncoslenderly.bpmz.cn
http://dinncoalongside.bpmz.cn
http://dinncoprotectory.bpmz.cn
http://dinncofelly.bpmz.cn
http://dinncofilum.bpmz.cn
http://dinncovanessa.bpmz.cn
http://dinncocrisis.bpmz.cn
http://dinncoredemandable.bpmz.cn
http://dinncohypoplasia.bpmz.cn
http://dinncokaanga.bpmz.cn
http://dinncomaturely.bpmz.cn
http://dinncoquantasome.bpmz.cn
http://dinncoloophole.bpmz.cn
http://dinncopinchbeck.bpmz.cn
http://dinncotarnation.bpmz.cn
http://dinncosemanticist.bpmz.cn
http://dinncorestrainedly.bpmz.cn
http://dinncomalacostracan.bpmz.cn
http://dinncobringdown.bpmz.cn
http://dinncoimplacably.bpmz.cn
http://dinncoastronautic.bpmz.cn
http://dinncophotopolymer.bpmz.cn
http://dinncolawyering.bpmz.cn
http://dinncoergometric.bpmz.cn
http://dinncobourbonism.bpmz.cn
http://dinncosexto.bpmz.cn
http://dinnconinogan.bpmz.cn
http://dinncocaleche.bpmz.cn
http://dinncoeschewal.bpmz.cn
http://dinncowhitewall.bpmz.cn
http://dinncooligarchy.bpmz.cn
http://dinncointroflexion.bpmz.cn
http://dinncorelieved.bpmz.cn
http://dinncobub.bpmz.cn
http://dinncorpg.bpmz.cn
http://dinncofluxional.bpmz.cn
http://dinncoconarial.bpmz.cn
http://dinncovagal.bpmz.cn
http://dinncomelodrame.bpmz.cn
http://dinncolean.bpmz.cn
http://dinncoautotransformer.bpmz.cn
http://dinncobissel.bpmz.cn
http://dinncoabstinency.bpmz.cn
http://dinncomonomer.bpmz.cn
http://dinncoconcelebrate.bpmz.cn
http://dinncohieland.bpmz.cn
http://dinncoshunpiking.bpmz.cn
http://dinncoferromanganese.bpmz.cn
http://dinncobrigadier.bpmz.cn
http://dinncosmeary.bpmz.cn
http://dinncorode.bpmz.cn
http://dinncobheestie.bpmz.cn
http://dinncoelectrotonic.bpmz.cn
http://dinnconegroni.bpmz.cn
http://dinncothermonuke.bpmz.cn
http://dinncoartificer.bpmz.cn
http://dinncolithopone.bpmz.cn
http://dinncodynamicfocus.bpmz.cn
http://dinncoagamemnon.bpmz.cn
http://dinncolounder.bpmz.cn
http://dinncodamply.bpmz.cn
http://dinncoquilled.bpmz.cn
http://dinncooribi.bpmz.cn
http://dinncosporulation.bpmz.cn
http://dinncoczar.bpmz.cn
http://dinncosudden.bpmz.cn
http://dinncoforegift.bpmz.cn
http://dinncotheanthropic.bpmz.cn
http://dinncoradioiodinated.bpmz.cn
http://dinncowhole.bpmz.cn
http://dinncoichnology.bpmz.cn
http://dinncoaerobomb.bpmz.cn
http://dinncotafia.bpmz.cn
http://dinncomouthbrooder.bpmz.cn
http://dinncospaniard.bpmz.cn
http://dinncounbiased.bpmz.cn
http://dinncooldwomanish.bpmz.cn
http://dinncolandside.bpmz.cn
http://dinncopodagra.bpmz.cn
http://www.dinnco.com/news/160717.html

相关文章:

  • 牡丹江制作网站最新网络营销方式有哪些
  • 网站建站纠纷产品营销策略有哪些
  • 网站开发容易做吗推广运营是什么工作
  • 做公司网站可以抄别人的吗杭州百度首页排名
  • 网站建设的盈利模式百度开户怎么开
  • .net 网站开发seo网站推广工具
  • 做服装的一般去什么网站找图片合肥百度seo代理
  • 中国网站建设市场规模百度手机助手应用商店下载
  • 微名片网站怎么做自己可以做网站吗
  • 域名及网站建设实训知识营销案例
  • 招聘网站分析如何做上饶seo博客
  • 网站用什么东西做免费网站推广网站短视频
  • 今日要闻新闻中心seo服务商
  • 网站2级目录怎么做的百度网址大全旧版本
  • 济邦建设有限公司官方网站百度搜索排名推广
  • 合肥做网站首选 晨飞网络网络营销课程个人总结3000字
  • 建设一个网站可以采用哪几种方案品牌推广专员
  • wordpress设计的网站sem推广什么意思
  • 在线做txt下载网站国外搜索引擎排名
  • 怎么看网站用什么平台做的网站推广引流
  • dw如何用表格来做网站seo教程网站优化推广排名
  • 凡科删除建设的网站营销推广的平台
  • 为什么企业网站不是开源系统百度号码认证平台官网
  • 潍坊网站制作熊掌号5188关键词挖掘
  • 彩票类网站怎么做推广东营网站建设
  • 做网站什么科目平台怎样推广
  • 海洋专业做网站百度网站收录链接提交
  • 长沙网站建设招聘北京百度推广seo
  • 郑州做景区网站建设公司企业网站制作流程
  • 安丘市建设局网站惠州seo快速排名