条件语句/循环

「Vue3系列」Vue3 条件语句/循环语句 在大多数情况下,Vue 的优化足以让这两种方式在性能上相差无几,因此选择哪种方式更多是基于代码的可读性和维护性的考虑。对于更复杂的条件逻辑,你可以使用计算属性来返回一个布尔值,并在模板中使用这个布尔值来决定是否渲染某个元素。是一个“真正的”条件渲染,因为它会确保在切换过程中条件块内的事件监听器和子组件适当地被销毁和重建。是惰性的:如果在初始渲染时条件为假,则什么也不做——直到条件第一次变为真时,才会开始渲染条件块。类似,但它不会基于条件来添加或移除元素,而是简单地切换元素的 CSS 的。 阅读详情

一、条件语句

1.if ------------ //判断语句为0为假,其他为真

if(判断语句){
}
else if(判断语句){
}
else{
}

2.switch(n) -------- //switch后面必须有大括号

-------------- //case和default没有先后顺序之分

------- //如果case中没有break,会继续进行下一个case中的语句

– //n只能是整形和枚举类型(类里定义的变量)

switch(n){
case(数字){语句}
case(数字){语句}
default{语句}
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	int  a = 0;
	scanf("%d", &a);
	switch (a) {
	case(1):
		printf("1");
		break;
	case(2):
		printf("2");
		break;
	case(3):
		printf("3");
		break;
	default:
		printf("ERROR");
		break;
	}
 }
//输入9*9乘法表
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
int arr[9][9] = { 0 };
for (int i = 0;i < 9;i++){
for (int j = 0;j < 9;j++) {
arr[i][j] = (i + 1) * (j + 1);
printf("%d*%d=%d ", (i + 1), (j + 1), arr[i][j]);
}
printf("\n");
}
printf("%d", arr[9][9]);
return 0;
  }

二、循环(continue-----------跳出当前循环,进行下一次循环 --------------------------------------- 跳出循环-------------------------------

1.for(赋值语句;条件语句;叠加){
}

#include <stdio.h>
int main() {
int count = 0;
for (int i = 1; i <= 100;i++) {
if (i % 10 == 9 || i / 10 == 9) {
count++;
}
}
printf("%d", count);
}

2.while(判断语句){
}
3.do{
}
while(判断语句)

PL/0到PL/1再到PL/2的扩展:掌握条件语句和循环结构 PL/0是一种简化版的教学编程语言,它以Pascal语言为基础,去除了很多高级特性,以便于更好地教授编译原理和语言设计。PL/0的语法和语义清晰简明,使得编译器的设计和实现过程更加直观易懂。 阅读详情

相关推荐

freeMark if嵌套

if的嵌套前段时间一直没有用过,用这个小例子看。能够很好理解 主要注意:这个括号

freemarker指令(九)

Freemarker指令 如果你没有在这里发现模板中的指令,可能你需要在废弃的 FTL 结构中来查找它了。 2.1 if ,else ,elseif  指令 2.1.1  概要 ... ... ... ... ... 这里:   condition , condition2 等:表达式将被计算成布尔值。 2.1.2  描述 你可以使用 if , els

一叶知春秋 6463

spdk + fio测试nvme 设备的性能

fio的测试对象可以是块设备、文件等,在spdk的使用过程中会unbind默认的nvme driver,所以在系统中是看不到nvme块设备的,在spdk中可以通过fio_plugin的方式,将spdk的用户态driver部分的io功能打包成一个ioengine提供给fio使用,可以综合spdk的高性能和fio提供的复杂场景。更多DPDK相关学习资料有需要的可以自行报名学习,免费订阅,永久学习,或点击这里加。这个jobfile是spdk中提供的例子。领取,关注我持续更新哦!2.7 jobfile的例子。

lingshengxiyou的博客 1089

(FreeMarker)if..else语句及比较

FreeMarker)if..else语句的语法格式为: <#if XXX> <#else if XXX> <#else if XXX> <#else> </#if> 如下: <div class="layui-col-md8 layui-col-sm8 layui-col-lg8"> <#if jib...

prime1019的博客 6337

Ubuntu1804 关于ubuntu18.04下载软件仓库信息失败,请检查网络连接 的解决方案

今天电脑在更换软件源的时候遇到了这个问题。出现了如上图所示的错误信息。 尝试了各家优快云的博客之后,发现方法大同小异,均无法解决。 方法大多都是要求更换软件源,如下所示: 打开“Ubuntu软件中心”-->点击“编辑”-->点击“软件源”-->在Ubuntu软件界面,“下载自”默认是“中国的服务器”,改为“主服务器”试试 2.打开更新管理器-》设置-》选择站点-》...

weixin_43729409的博客 1万+

Anaconda镜像源切换全攻略:从清华源到恢复默认设置的完整流程

本文详细介绍了Anaconda镜像源的管理与优化,重点讲解了如何配置清华源以提升国内下载速度。内容涵盖镜像源工作原理、清华源详细配置步骤、多源管理策略、常见问题排查以及如何安全恢复默认设置,帮助用户构建完整的镜像源管理体系。

weixin_28828243的博客 1021

SpringBoot+elasticsearch+JerseyRESTful +redis博客系统

包含技术Linux、Redis、spring boot、文件上传下载、FreeMarker、thymeleaf、spring jdbc、Spring Data JPA、 MyBatis、 Mybatis Generator逆向生成、CKEditor、AJAX异步上传文件、Jersey实现应用服务器和文件服务器分离、Elasticsearch

张量/数组存储方式与向量化展开/展平、view、reshape、permute对比

对于一个Tensor来说,我们可以认为它有两种存储方式。

欢迎关注,共同进步! 3434

FreeMarker--03---常见指令、运算符

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录FreeMarker 常见指令[官网 FreeMarker---指令参考](http://freemarker.foofun.cn/ref_directives.html)![在这里插入图片描述](https://img-blog.csdnimg.cn/1edc5d12dcad41f0b0456c3374e4e9cd.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJ

时光里的博客 2212

把对讲门铃(控制底楼铁门)接入米家服务器

今天讲个跟SDR或者无人机无关的东西,技术含量不高,但是方便了我的生活。 现在家门有智能锁,汽车也可以远程解锁发动,NFC门禁也可以用某些手机复制,唯独楼下的铁门,必须用老式对讲门铃控制。 也就是说其它钥匙都可以不带,就剩这个钥匙还必须随身携带。 另外有时候人不在家,不能开楼下铁门,快递员也没法把东西送上楼。 ......

老邵的开源世界 6551

LVGL 磁罗盘效果

环境:LVGL 9.x + SDL2,窗口 1280×800。界面文案用英文(默认 Montserrat,无 CJK)。本文按实现顺序讲:先建立两个耦合转动体,再把磁倾角误差从卡面倾斜里推出来,最后用同一套投影把刻度、数字和目标画到卡上。画面上的迟滞、涡流、摆动和读数偏差都来自方程,没有补间动画。

摸鱼专家 88

JS各种循环语句/条件语句的性能

循环语句 JS中常见的循环函数有 for while do while for in forEach for in 一般是用在对象属性名的遍历上的,由于每次迭代操作会同时搜索实例本身的属性以及原型链上的属性,所以效率肯定低下 而forEach是基于函数的迭代(需要特别注意的是所有版本的ie都不支持,如果需要可以用JQuery等库),对每个数组项调用外部方法所带来的开

前端学习日记 5478

初学者入门YOLO目标检测:从懵圈到上手,这篇文章讲透所有核心(附学习路径+避坑指南)

目标:比如训练一个“检测苹果和橘子”的模型,或者“检测人脸”的模型;任务:学会用LabelImg标注数据,制作YOLO格式的数据集,用命令行训练模型;关键:不用追求高精度,能训练出一个能检测出目标的模型就行。很多初学者卡在入门阶段,不是因为智商不够,而是因为“想太多,做太少”——总觉得要把所有原理搞懂才能动手,结果越想越怕,最后放弃。先动手,再动脑。先跑通一个案例,获得成就感;再制作自定义数据集,训练简单模型;最后再回头去理解原理,优化模型。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 690

循环结构 / 条件语句

Java循环结构 顺序结构的程序语句只能被执行一次。如果您想要同样的操作执行多次,,就需要使用循环结构。 Java中有三种主要的循环结构: while 循环 do…while 循环 for 循环 1 . while 循环 while是最基本的循环,它的结构为: while( 布尔表达式 ) { //循环内容 } 只要布尔表达式为 true,循环就会一直执行下去。 实例 public cl...

xiaoyuxiaoning的博客 370

双Orin PCIe RC&EP模式互通

orin pcie 互通

乐于分享 3877

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

JS中的条件语句/循环语句/跳转语句

条件语句switch case语句switch(表达式){ case 数值1:执行语句1; break; case 数值2:执行语句2; break; default:语句块; } break语句编写位置有两种: 1、常用应该是所有case语句的最后面——不用break; 2、放置在非最后面的位置——需要添加break,不然结果不正确,它会把有break之

木头房子的格子铺 2229

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Swift循环与条件语句:gh_mirrors/swi/swift-style-guide中的最佳实践

你是否也曾面对嵌套多层的if-else代码感到头痛?是否在调试循环逻辑时迷失在复杂的条件判断中?本文将带你深入学习gh_mirrors/swi/swift-style-guide项目中的循环与条件语句最佳实践,让你的代码更清晰、更易读、更健壮。读完本文后,你将能够掌握Swift中控制流的优雅写法,避免常见的代码陷阱,编写出符合专业标准的Swift代码。 ## 控制流基础:从if-else到循环的...

gitblog_01007的博客 981

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Oracle 条件语句/循环语句

 一 IF..THENIF condition THEN   statements 1;   statements 2;   ....END IF;二 IF..THEN...ELSEIF condition THEN   statements 1;   statements 2;   ....ELSE   statements 1;   statements 2;   ....END IF;三 I

hdhai9451的专栏 1763

7.for/while循环与if条件语句

1.if语句 2.while循环 3.for循环

恸流失的博客 1037

(六)Go语言的基础语法-循环/条件语句/函数/指针

一. Go的if条件语句 Go语言的if条件语句特点: 1.支持正常写法,但无需括号 *2.可以在if条件里赋值变量,但对应的作用域也只在if条件语句里 二. Go的switch条件语句 Go语言的switch条件语句特点: 1.没有break,除非使用fallthrough 2.switch后可以没有表达式 三. ...

WatermelonMk的博客 271

java练习题:根据try-catch/for循环/while循环/if条件语句/scanner 1

摘要:本文详细讲解了如何用Java编写程序来记录学生成绩范围。程序使用Scanner实现用户交互,通过while(true)循环持续接收输入,当输入0时退出程序。代码设置了double类型的min和max变量(初始化为Double.MAX_VALUE和Double.MIN_VALUE),在每次输入合法成绩后更新成绩范围。程序包含错误处理机制:检测负数成绩、使用try-catch捕获输入异常(如输入字母)。最终程序会实时输出当前成绩的最小值和最大值范围。

2301_76578848的博客 1053

python - 条件语句/循环语句/迭代器

条件测试:if 条件表达式python 的比较操作 所有的python对象都支持比较操作 可用于测试相等性、相对大小等 如果是复合对象,python会检查其所有部分,包括自动遍历各级嵌套对象,知道可以得出最终结果。 测试操作符 ‘==’操作符测试值得相等性 'is'...

dixian4894的博客 153

02-javascript条件语句/分支结构语句/循环语句

1、If 条件语句 if(条件) { } ()里面的条件最终湖岸转换为布尔值 if…else if…else if …else 2、三目运算符 条件 ? 条件成立执行的代码 : 条件不成立执行的代码 var a = 10 if(a > 10){ alert('哈哈') }else{ alert('嘻嘻') } var a = 10 a > 10 ? alert('哈哈') : alert('嘻嘻') 3、switch switch(你要判断的变

weixin_53841588的博客 142
上一篇: 一些琐碎的C语言知识
下一篇: str函数
Code_Paradise
博客等级 码龄7年 6粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值