测试代码复制
umzs2020-12-21 12:08:02次浏览
actionscript3
public function listArray():void { // 测试数组 直接放 1到数组中,Array默认是Number类型,不是int类型 var list:Array = new Array("name",1,"sex"); trace("******************** for()*******************"); trace("for是循环遍历,序列从给出的下标开始 如i=0到list.legth"); for(var i:int=0;i<list.length;i++) { trace("list["+i+"]="+list[i]); // list[0]=name // list[1]=1 // list[2]=sex } trace("***for( var item:ObjectType in Array)*******"); trace("***得到的是数组元素(即下标)或者对象属性 *******"); for( var item:String in list) { trace("item="+item+" list[item]="+list[item]); // item=0 list[item]=name // item=1 list[item]=1 // item=2 list[item]=sex } trace("***for(var item:String in array)和 typeOf()**"); trace("***用typeof()来判定特定类型子集 **"); for each( var items:String in list) { if(typeof(list[items])=="number") trace("item="+items+" list[item]="+list[items]); // item=1 list[item]=1 } trace("***for each( var in array) 遍历子集 *********"); for each( var element:Object in list) { trace("element="+element); // element=name // element=1 // element=sex } trace("*** element is type 判定数据类型 *********"); var j:int=0; for each( var e:Object in list) { if(e is String) trace("list["+j+"] is a String="+e); // list[0] is a String=name // list[2] is a String=sex if(e is Number) trace("list["+j+"] is a Number="+e); // list[1] is a Number=1 j++; } }
java
public class Demo6Array { public static void main(String[] args) { int sum = 0; int[][] arr = {{22, 66, 44}, {77, 33, 88}, {25, 45, 65}, {11, 66, 99}}; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { sum += arr[i][j]; } } System.out.println("sum=" + sum); } }
python
#!/usr/bin/env python # -*- coding:utf-8 -*- #定义初始值,sum指的是总和,start指的是1-100的整数 sum=0 start=1 while True: if start==101: break #%运算是取余数,判断是奇数还是偶数 if start%2 ==1: sum=sum+start if start%2 ==0: sum=sum-start start +=1 print sum
C
#include int main(void) //一个简单的 C程序 { int num; //定义一个名为 num 的变量 num = 1 ; //为num赋一个值 printf("我是一个简单的"); //使用 printf() 函数 printf("计算机.\n"); printf("我最喜欢的号码是 %d 因为它是第一个.\n",num); return 0; }
BASH
#!/bin/bash echo "Hello World !"
CSS
.menu:before { position: absolute; content: ""; top: 22px; right: 5px; background: url(../images/jt.png) no-repeat; width: 8px; height: 8px; -ms-transition: all .5s ease; -moz-transition: all .5s ease; -webkit-transition: all .5s ease; -o-transition: all .5s ease; transition: all .5s ease; } .menu:hover:before { transform: rotate(180deg) }/*旋转*/ #mnavh { display: none; margin: 5px 0 0 0; width: 24px; height: 40px; float: right; text-align: center; padding: 0 6px; } .navicon { display: block; position: relative; width: 30px; height: 5px; background-color: #fff; margin-top: 20px; } .navicon:before, .navicon:after { content: ''; display: block; width: 30px; height: 5px; position: absolute; background: #fff; -webkit-transition-property: margin, -webkit-transform; transition-property: margin, -webkit-transform; transition-property: margin, transform; transition-property: margin, transform, -webkit-transform; -webkit-transition-duration: 300ms; transition-duration: 300ms; } .navicon:before { margin-top: -10px; } .navicon:after { margin-top: 10px; } .open .navicon { background: none } .open .navicon:before { margin-top: 0; -webkit-transform: rotate(45deg); transform: rotate(45deg); } .open .navicon:after { margin-top: 0; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); } .open .navicon:before, .open .navicon:after { content: ''; display: block; width: 30px; height: 5px; position: absolute; background: #fff; } /*menu+*/ .menu span { display: none; width: 50px; height: 50px; background: #12b7de; opacity: 0.5; position: absolute; top: 0; right: 0; border-left: #49ccea 1px solid; } /*search*/ .searchico { margin-top: 5px; width: 39px; height: 39px; float: right; display: inline; cursor: pointer; background: url(../images/bg.png) no-repeat center !important; } .searchbox { width: 1200px; margin: 10px auto; overflow: hidden; background: #ffffff; position: relative; } .search { width: 50%; margin: 20px auto; background: #222; border-radius: 0 5px 5px 0; position: relative; border: #ccc 1px solid; display: none; } .search input.input_submit { border: 0; background: 0; color: #fff; outline: none; position: absolute; top: 10px; right: 10% } .search input.input_text { border: 0; line-height: 36px; height: 36px; width: 72%; padding-left: 10px; outline: none } .open { display: block !important } .searchclose { background: url(../images/close.png) no-repeat; display: block; position: absolute; width: 28px; height: 30px; right: 5px; top: 5px }
DELPHI
program Project1;{$APPTYPE CONSOLE}//uses// SysUtils; {这两行,在本程序中无用,如果带着程序大小是:44.5k; 注释掉程序是19k}begin Writeln('ok'); Readln;end.
ERLANG
-module(hello).2 -export([start/0]).3 4 start() ->5 io:format("Hello world~n").
GROOVY
import static java.lang.String.format class SomeClass { String format(Integer i) { i.toString() } static void main(String[] args) { assert format('String') == 'String' //在Java中编译不会通过 assert new SomeClass().format(Integer.valueOf(1)) == '1' } }
HTML
LondonLondon is the capital city of England.It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.ParisParis is the capital and most populous city of France.
javascript
//1、for重复执行某些代码,通常跟计数有关系 //2、for语法结构 for(初始化变量; 条件表达式; 操作表达式){ //循环体 } //3、初始化变量 就是用var声明一个普通变量,通常用于作为计数器使用 //4、条件表达式 用来决定每一次循环是否继续执行 终止的条件 //5、操作表达式 是每次循环最后执行的代码 常用于计数器变量进行更新 (递增或递减)
perl
#!/usr/bin/perl @hits = (25, 30, 40); @names = ("google", "runoob", "taobao"); print "\$hits[0] = $hits[0]\n";print "\$hits[1] = $hits[1]\n";print "\$hits[2] = $hits[2]\n";print "\$names[0] = $names[0]\n";print "\$names[1] = $names[1]\n";print "\$names[2] = $names[2]\n";
PHP
$h51701 = array( "group1"=>array( array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男") ), "group2"=>array( array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男") ), "group3"=>array( array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男"), array("name"=>"张三","age"=>14,"sex"=>"男") ) ); foreach ($h51701 as $key => $value) { echo "{$key} "; foreach ($value as $key1 => $value1) { echo "第".($key1+1)."个同学 "; foreach ($value1 as $key2 => $value2) { echo "{$key2}==>{$value2} "; } echo " "; } echo "------------------------ "; }
RUBY
#!/usr/bin/ruby# -*- coding: UTF-8 -*-$i = 0$num = 5while $i < $num do puts("在循环语句中 i = #$i" ) $i +=1end
SCALA
object Test { def main(args: Array[String]) { var a = 10; // 无限循环 while( true ){ println( "a 的值为 : " + a ); } } }
SQL
declare @ID int;--声明变量(@名称 类型) begin--开始 print '示例'--输出 declare a_test_main cursor for select ID from TableName1--查出需要循环的集合放到游标中 open a_test_main;--打开游标 while 1=1--开始循环 begin--开始 fetch next from a_test_main into @ID--赋值到变量中 if(@@fetch_status!=0)break;--如果没有结果退出循环 if not exists(select * from TableName2 where ID = @ID)--判断不存在数据 begin--开始 print '新增'--输出 insert into TableName2 (ID)values(@ID)--不存在数据时执行(新增) end--结束 if exists(select * from TableName3 where ID = @ID)--判断存在数据 begin--开始 print '修改'--输出 update TableName3 set ID = 1 where ID = @ID--存在数据时执行(修改) end--结束 if exists(select * from TableName4 where ID = @ID)--判断存在数据 begin--开始 print '删除'--输出 delete from TableName4 where ID = @ID--存在数据时执行(删除) end--结束 end--结束 close a_test_main--关闭游标 deallocate a_test_main--释放游标 end--结束
VB
Private Sub Form_Load() For i = 1 To 100 MsgBox i, vbInformation /vbInformation 指显示图标,下同 Next MsgBox "Finished", vbCritical End Sub
XML
GeorgeJohnReminderDon't forget the meeting!