1.一张纸的厚度是0.0001米,将纸对折,对折多少次厚度超过珠峰高度8848米 解法一: var gd = 8848; var cs = 0; while(true) { cs++; gd = gd*0.5 if(gd<0.0001) { break; } } alert(cs); 解法二: var n = 0; var g = 0.0001; while(true) { g = g *2; n++ if(g>8848) { break } } alert(n); 解法三: var n =…
1.基础定义 for语句的条件不需要括号(同if语句) ,golang里的循环只有for,没有while sum := 0 for i=0;i<100;i++ { sum += i } 2.条件省略 for语句的条件可以省略初始条件,结束条件,递增表达式 省略初始条件,相当于while sum,i := 0,0 for ;i<100;i++ { sum += i } 省略初始条件和递增表达式 file,err := os.Open("a.txt") if err != ni…
//: Playground - noun: a place where people can play import UIKit /*: for循环 * 基本用法和OC一致 * 条件表达式必须是bool类型的值 * 条件表达式的()可以省略 * 在OC中如果{}中只有一条语句, 那么{}可以省略, 而Swift不可以 */ for var i = 0; i < 10; i++ { print(i) } /*: 区间 半闭区间: 0..<10 包含头不包含尾 闭区间: 0...10 包…
刚刚开始学习ROS,打算入机器人的坑了,参考教材是<ROS及其人开发实践>胡春旭编著 机械工业出版社 华章科技出品.本来以为可以按照书上的步骤一步步来,但是,too young to simple啊,程序员的苦逼日子开始了,特地记录如下. 在学习ROS的helloworld程序时,发现,ROS中居然使用cmake编译,头大,一不做二不休,看书练习.记录如下,环境kubuntu 18.04系统,最新升级的,目录/home/municationk/WORKM/cmake/t1 两个文件main.c…
1.Lua保留的关键字: and,bread,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return ,then,true,until,while 2.字符串多行显示 a = [[multiple line with ''single' and "double" quoted strings inside.]] 3.支持同时定义多个变量 a,b,c,d = ,,"louis"…