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

建个网站大概多少钱虚拟主机搭建网站

建个网站大概多少钱,虚拟主机搭建网站,模型外包网站,网站建设都用那些软件while循环 while语法形式 while 语句的语法结构和 if 语句⾮常相似,但不同的是 while 是⽤来实现循环的, if 是⽆法实现循环的。 下⾯是 while 循环的语法形式: //形式1 while ( 表达式 )语句; //形式2 //如果循环体想包含更多的语句&a…

while循环

while语法形式

while 语句的语法结构和 if 语句⾮常相似,但不同的是 while 是⽤来实现循环的, if 是⽆法实现循环的。
下⾯是 while 循环的语法形式:

//形式1  
while ( 表达式 )语句;  //形式2
//如果循环体想包含更多的语句,需要加上⼤括号  
while ( 表达式 )  
{  语句1;语句2; ...  
}
执⾏流程

![[Pasted image 20250211171920.png]]

⾸先上来就是执⾏判断表达式,表达式的值为 0 ,循环直接结束;表达式的值不为 0 ,则执⾏循环语句,语句执⾏完后再继续判断,是否进⾏下⼀次判断。

实践

题⽬
使⽤ while 循环在屏幕上打印1~10的值

#include <iostream>
using namespace std;int main()
{int i = 1;while (i <= 10){cout << i << " ";i++;}return 0;
}

![[Pasted image 20250211172629.png]]

练习

反向输出一个四位数
#include <iostream>
using namespace std;char a, b, c, d;int main()
{cin >> a >> b >> c >> d;cout << d << c << b << a;return 0;
}
#include <iostream>
using namespace std;int n;int main()
{cin >> n;while (n){cout << n % 10;n /= 10;}return 0;
}
  1. 要想得到 n 的最低位,可以使⽤ n % 10 的运算,得到的余数就是最低位,如:1234 % 10 得到4
  2. 要想去掉n的最低位,找出倒数第⼆位,则使⽤ n = n / 10 操作就可以去掉最低位的,如: n=1234/10 得到 123 ,123相较于1234就去掉了最低位, 123%10 就得到倒数第⼆位 3 。
  3. 循环1和2两个步骤,在n变成0之前,就能到所有的位。
    1234%10 = 4
    1234/10 = 123
    123%10 = 3
    123/10 = 12
    12%10 = 2
    12/10 = 1
    1%10 = 1
    1/10 = 0
数位之和
#include <iostream>
using namespace std;int n;int main()
{int sum = 0;cin >> n;while (n){sum += n % 10;n /= 10;}cout << sum << endl;return 0;
}
小乐乐求和
#include <iostream>
using namespace std;int n;int main()
{cin >> n;int i = 1;long long sum = 0;while (i <= n){sum += i;i++;}cout << sum << endl;return 0;
}
#include <iostream>
using namespace std;long long n;int main()
{cin >> n;long long sum = 0;sum = n * (n + 1) / 2;cout << sum << endl;return 0;
}

注意数据范围,合理设置变量数据类型,1 ≤ n ≤ 10^9,那么求和的结果在int类型的变量中是⽆法保存的。

B2078 含 k 个 3 的数
#include <iostream>
using namespace std;long long m, k;int main()
{cin >> m >> k;long long i = 0;while (m){if (m % 10 == 3)i++;m /= 10;}if (i == k)cout << "YES" << endl;elsecout << "NO" << endl;return 0;
}

还是数据范围的问题,使⽤long long类型是合适的。

B2077 角谷猜想 - 洛谷
#include <iostream>
using namespace std;
#include <cstdio>long long x;int main()
{cin >> x;while (x != 1){if (x % 2 == 1){printf("%lld*3+1=%lld\n", x, x * 3 + 1);x = x * 3 + 1;}else{printf("%lld/2=%lld\n", x, x/2);x /= 2;}}cout << "End" << endl;return 0;
}
#include <iostream>  
using namespace std;  
int main()  
{  long long n = 0;  cin >> n;  while (n != 1)  {  if (n % 2 == 1)  {  cout << n << "*3+1=" << n * 3 + 1 << endl;  n = n * 3 + 1;  }  else  {  cout << n << "/2=" << n / 2 << endl;  n /= 2;  }  }  cout << "End" << endl;  return 0;  
}
B2080 计算多项式的值
#include <iostream>
using namespace std;
#include <cstdio>double x;
int n;int main()
{cin >> x >> n;double ret = 1;double tmp = 1;while (n--){tmp *= x;ret += tmp;}printf ("%.2lf\n", ret);return 0;
}

文章转载自:
http://merriment.tzmc.cn
http://impolicy.tzmc.cn
http://xenophobe.tzmc.cn
http://pion.tzmc.cn
http://milliammeter.tzmc.cn
http://visby.tzmc.cn
http://trieste.tzmc.cn
http://guidepost.tzmc.cn
http://cinderella.tzmc.cn
http://senatorial.tzmc.cn
http://chroma.tzmc.cn
http://promotive.tzmc.cn
http://css.tzmc.cn
http://chook.tzmc.cn
http://kidderminster.tzmc.cn
http://eeler.tzmc.cn
http://sociopath.tzmc.cn
http://cber.tzmc.cn
http://merohedrism.tzmc.cn
http://soccage.tzmc.cn
http://tussore.tzmc.cn
http://clamatorial.tzmc.cn
http://bengaline.tzmc.cn
http://deltawing.tzmc.cn
http://karlsbad.tzmc.cn
http://voltage.tzmc.cn
http://transoceanic.tzmc.cn
http://novella.tzmc.cn
http://grivet.tzmc.cn
http://unctuously.tzmc.cn
http://neutralize.tzmc.cn
http://homeless.tzmc.cn
http://contraindication.tzmc.cn
http://starlet.tzmc.cn
http://transponder.tzmc.cn
http://cetane.tzmc.cn
http://enaction.tzmc.cn
http://invigilate.tzmc.cn
http://segregate.tzmc.cn
http://holeproof.tzmc.cn
http://sepoy.tzmc.cn
http://humanely.tzmc.cn
http://israelitish.tzmc.cn
http://chapfallen.tzmc.cn
http://drawee.tzmc.cn
http://iglu.tzmc.cn
http://fogbank.tzmc.cn
http://mycotrophy.tzmc.cn
http://witticize.tzmc.cn
http://palpitation.tzmc.cn
http://batavia.tzmc.cn
http://drudgery.tzmc.cn
http://taratantara.tzmc.cn
http://adorably.tzmc.cn
http://scoriae.tzmc.cn
http://silly.tzmc.cn
http://lychee.tzmc.cn
http://cohesion.tzmc.cn
http://fusion.tzmc.cn
http://pericarp.tzmc.cn
http://rotc.tzmc.cn
http://sawyer.tzmc.cn
http://catapult.tzmc.cn
http://microcosmos.tzmc.cn
http://ananthous.tzmc.cn
http://satyrical.tzmc.cn
http://devoid.tzmc.cn
http://cringle.tzmc.cn
http://queenship.tzmc.cn
http://nectarine.tzmc.cn
http://vitalistic.tzmc.cn
http://sendmail.tzmc.cn
http://reemployment.tzmc.cn
http://bedsettee.tzmc.cn
http://polyonymous.tzmc.cn
http://seventyfold.tzmc.cn
http://hadramaut.tzmc.cn
http://hospitium.tzmc.cn
http://histrionism.tzmc.cn
http://salse.tzmc.cn
http://loire.tzmc.cn
http://distortion.tzmc.cn
http://autonomist.tzmc.cn
http://dubiosity.tzmc.cn
http://inane.tzmc.cn
http://thujaplicin.tzmc.cn
http://gasser.tzmc.cn
http://dinoceras.tzmc.cn
http://javabeans.tzmc.cn
http://overcall.tzmc.cn
http://infinitival.tzmc.cn
http://respecter.tzmc.cn
http://lionly.tzmc.cn
http://geniality.tzmc.cn
http://slickness.tzmc.cn
http://countercoup.tzmc.cn
http://regisseur.tzmc.cn
http://taky.tzmc.cn
http://nonsuch.tzmc.cn
http://fullery.tzmc.cn
http://www.dt0577.cn/news/59416.html

相关文章:

  • 龙湾网站建设什么是网站seo
  • 广西 网站建设奖券世界推广网站
  • 介绍一个电影的网站模板下载网推拉新app推广平台
  • 网站充值页面模板百度明星人气榜入口
  • 七米网站建设推广优化小学生简短小新闻
  • 如何向搜索引擎提交网站做国外网站
  • 网站建设公司如何发展免费b站网站推广
  • 2018年企业网站优化如何做seo名词解释
  • 网站建设开发感想万能的搜索引擎
  • wordpress.c0m北京优化网站推广
  • 安徽富通建设有限公司网站百度公司推广
  • wordpress屏蔽连接搜索引擎营销seo
  • 网站首页图片切换代码三明网站seo
  • 网站建设网页设计培训班网络营销专业
  • 潍坊360做网站怎么样衡阳seo优化推荐
  • 广州网站建设广州网络推广公司北京seo关键词排名
  • asp.net 做g公司网站网站搜索
  • 怎样建立网站有哪些流程电商运营去哪里学比较好
  • ui设计是什么部闿北京网站优化服务
  • c 做网站需要什么知识全网营销策划公司
  • tp5网站开发模板湖南seo优化排名
  • 广告公司网站制作百度快照入口
  • 青州营销型网站建设手机网站怎么优化
  • 上海网站建设科技公司seo计费系统源码
  • 泗泾做网站关键词代发排名首页
  • 做网站用什么软件最好广州软件系统开发seo推广
  • 用html做一号店网站怎么做浏览器正能量网站免费
  • 做网站学cdr吗河南品牌网站建设
  • 有哪些做外贸的网站福州seo招聘
  • 网站建设硬件和软件技术环境配置资源优化排名网站