aardio 官方社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 55980|回复: 71

发挥你的创意,大家一起来写Hello world!

  [复制链接]

166

主题

2129

回帖

1万

积分

管理员

积分
12931
发表于 2012-11-12 13:47:50 | 显示全部楼层 |阅读模式
“Hello, world!" 的意思是:“世界,你好!”

有一个经典的编程语言入门程序:
就是在计算机屏幕上显示一条信息 “Hello, world!"

这个例程因为在Brian Kernighan 和 Dennis M. Ritchie 合著的《The C Programme Language》使用而广泛流行。因为它的简洁,实用,并包含了一个程序所应具有的一切,因此为后来的编程类图书的作者提供了范例,一直待续到今。

Hello, world程序通常面向的是零基础的新手,
是迈向编程世界大门的第一步,当然程序可以不局限于输出一句 “Hello, world!" ,可使用各种不同的显示方法显示信息,但前提是该程序能让零基础的新手读懂、学会、并能有所领悟,消除对编程语言的陌生感。

下面希望大家发挥创意,在后面回帖留下你的Hello world程序。

请注意:
1、不是发表程序的回复,请大家尽量使用帖子点评功能。
2、代码一定要规范整齐,注意缩进有序、合适对齐,不要包含不必要的空行或注释,并添加必要的注释。

0

主题

33

回帖

276

积分

二级会员

积分
276
发表于 2012-11-12 13:56:05 | 显示全部楼层
本帖最后由 ╰簬飝_⑤⑥壹╯ 于 2012-11-12 14:25 编辑

此贴必火,先占一楼,晚上下班回家写!



import process
import winex;
import key;

//打开写字板
process.execute("wordpad.exe");
winex.waitActive(,,
"WordPadClass","RICHEDIT50W");

key.sendString(
"hello world! 欢迎您来到aardio的世界~!")






//记事本打字效果
import process;
import winex;
import string.mbcs;


sendinput =
function( str ){
   
var mbcs = string.mbcs(str);
   
for(i=1;#mbcs){
        winex.say(mbcs[ i ]);
        
sleep(200)
    }
   
}

process.execute_waitInput(
"notepad.exe");
sendinput(
"hello world! 欢迎您来到aardio的世界~!" )


评分

参与人数 1 +5 收起 理由
edians + 5 很给力!

查看全部评分

13

主题

92

回帖

719

积分

三级会员

积分
719
QQ
发表于 2012-11-12 14:04:14 | 显示全部楼层
  1. import console;//打开控制台
  2. str="hello world"
  3. tab=string.split(str)
  4. for(i=1;#tab;1){
  5.         console.log(tab[i])
  6. }

  7. console.pause() //按任意键继续
  8. ;//关闭控制台
复制代码

点评

这样写也可以 for(i=1;#str){ io.print(str [[i]] ) } 要注意是使用两对方括号放索引取出来的就是字符(一对中括号取出来的是字节码数值).  发表于 2012-11-12 14:11

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 很给力!

查看全部评分

4

主题

9

回帖

162

积分

一级会员

积分
162
发表于 2012-11-12 14:06:34 | 显示全部楼层

import console;
console.log("hello world");

评分

参与人数 1 +50 +50 收起 理由
JacenHe + 50 + 50 很给力!

查看全部评分

26

主题

75

回帖

649

积分

荣誉会员

积分
649
发表于 2012-11-12 14:19:15 | 显示全部楼层
import win.util.tray;
win.util.tray.pop(
"hello world");

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 这个不错,用托盘提示显示信息

查看全部评分

0

主题

6

回帖

43

积分

新手入门

积分
43
发表于 2012-11-12 14:21:14 | 显示全部楼层
import console;
console.log("Hello, world!")
console.pause()
;

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 很给力!

查看全部评分

4

主题

9

回帖

162

积分

一级会员

积分
162
发表于 2012-11-12 14:22:07 | 显示全部楼层
import win.ui;
win.msgbox(
"hello world")

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 不错,使用消息对话框显示信息

查看全部评分

26

主题

75

回帖

649

积分

荣誉会员

积分
649
发表于 2012-11-12 14:29:54 | 显示全部楼层
import process;
process.execute_waitInput(
"notepad.exe");
import winex;
var str= 'hello world...\r\nplease continue!';
for(i=1;#str;1){
    winex.sayIme( ..string.pack(str[ i ]));
    win.delay(50);
}

评分

参与人数 1 +200 +200 收起 理由
JacenHe + 200 + 200 这个强悍

查看全部评分

7

主题

39

回帖

425

积分

培训班

积分
425
发表于 2012-11-12 14:30:57 | 显示全部楼层
  1. import php;////重置解释器

  2. //PHP代码
  3. phpcode =/*
  4.         $a=chr(0x48).chr(0x65).chr(0x6C).chr(0x6C).chr(0x6F);
  5.         $b=chr(0x20).chr(0x77).chr(0x6F).chr(0x72).chr(0x6C).chr(0x64)."!";
  6.         echo $a.$b;

  7. */
  8. import console;//打开控制台
  9. php.exec(phpcode) ;//运行PHP代码,返回表达式的值
  10. console.log( php.a +php.b); //取php变量
  11. console.pause() //按任意键继续
  12. ;//关闭控制台
复制代码

评分

参与人数 1 +200 +200 收起 理由
JacenHe + 200 + 200 真棒,调用PHP获取数据

查看全部评分

20

主题

49

回帖

476

积分

二级会员

积分
476
发表于 2012-11-12 14:31:03 | 显示全部楼层
//重在参与

import win.ui;
/*DSG{{*/
var winform = ..win.form( bottom=399;parent=...;text="aardio Form";right=599 )
winform.add(
static={ bottom=194;color=255;right=521;left=88;top=149;font=LOGFONT( h=-29 );z=1;transparent=1;cls="static" }
)
/*}}*/

import php;

//PHP代码
phpcode =/*
        $abc = "hello world";
*/

//运行PHP代码,返回表达式的值
php.exec(phpcode)

winform.static.text = php.abc;

winform.show();
win.loopMessage();

评分

参与人数 1 +200 +200 收起 理由
JacenHe + 200 + 200 很给力!

查看全部评分

6

主题

60

回帖

514

积分

荣誉会员

积分
514
发表于 2012-11-12 14:53:45 | 显示全部楼层
import win.ui;
/*DSG{{*/
mainForm = ..win.form( bottom=400;parent=...;right=600;text=
"aardio Form" )
mainForm.add(  )
/*}}*/

mainForm.text=
'hello world';

mainForm.show() ;
win.loopMessage();

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 很给力!

查看全部评分

5

主题

41

回帖

319

积分

二级会员

积分
319
发表于 2012-11-12 15:19:22 | 显示全部楼层
  1. import win.ui;
  2. /*DSG{{*/
  3. var winform = ..win.form( bottom=47;parent=...;text="aardio Form";right=116 )
  4. winform.add(
  5. static={ bottom=39;text="Hello, world!";left=24;top=18;z=1;transparent=1;right=93;cls="static" }
  6. )
  7. /*}}*/

  8. winform.show();
  9. win.loopMessage();
复制代码

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 很给力!

查看全部评分

7

主题

39

回帖

425

积分

培训班

积分
425
发表于 2012-11-12 15:40:13 | 显示全部楼层
本帖最后由 zhoubujin 于 2012-11-12 15:48 编辑

我是WIN7系统的 需要 把画布 拉的大点 快捷键没找到. 我的分辨率是 1440* 900. 就写了个 HELLO   测试一哈吧

未命名.jpg
import process;
import key;
import mouse;
process.execute_waitInput("mspaint.exe"); //画板
win.delay(500)//延迟
key.combine("alt","space","x")//画板最大化


//H
mouse.move(10,200,true) //模拟鼠标 移动位置到 X Y
mouse.down()//模拟鼠标 按下左键
mouse.move(10,300,true)//模拟鼠标 移动位置到 X Y
mouse.up() //模拟鼠标 松开左键

win.delay(500)//延迟 出现画的效果  一下以此类推

mouse.move(10,250,true)
mouse.down()
mouse.move(60,250,true)
mouse.up()

win.delay(500)

mouse.move(60,200,true)
mouse.down()
mouse.move(60,300,true)
mouse.up()

//E

win.delay(500)

mouse.move(110,200,true)
mouse.down()
mouse.move(160,200,true)
mouse.up()


win.delay(500)

mouse.move(110,200,true)
mouse.down()
mouse.move(110,300,true)
mouse.up()

win.delay(500)

mouse.move(110,250,true)
mouse.down()
mouse.move(160,250,true)
mouse.up()


win.delay(500)

mouse.move(110,300,true)
mouse.down()
mouse.move(160,300,true)
mouse.up()


//L

win.delay(500)

mouse.move(210,200,true)
mouse.down()
mouse.move(210,300,true)
mouse.up()


win.delay(500)

mouse.move(210,300,true)
mouse.down()
mouse.move(260,300,true)
mouse.up()

//L

win.delay(500)

mouse.move(310,200,true)
mouse.down()
mouse.move(310,300,true)
mouse.up()


win.delay(500)

mouse.move(310,300,true)
mouse.down()
mouse.move(360,300,true)
mouse.up()

//O

win.delay(500)

mouse.move(410,200,true)
mouse.down()
mouse.move(460,200,true)
mouse.up()

win.delay(500)

mouse.move(460,200,true)
mouse.down()
mouse.move(460,300,true)
mouse.up()



win.delay(500)

mouse.move(460,300,true)
mouse.down()
mouse.move(410,300,true)
mouse.up()



win.delay(500)

mouse.move(410,300,true)
mouse.down()
mouse.move(410,200,true)
mouse.up()

评分

参与人数 1 +300 +300 收起 理由
JacenHe + 300 + 300 很有创意

查看全部评分

6

主题

44

回帖

587

积分

荣誉会员

积分
587
发表于 2012-11-12 15:52:25 | 显示全部楼层
范例里抄的
//GDI+绘图演示

import win.ui;
import win.ui.menu;
import com.picture;
/*DSG{{*/
var winform = ..win.form( bottom=424;parent=...;text="aardio Form";right=566 )
winform.add(
btnDrawString={ bottom=374;text=
"GDI+ 输出文字";left=68;top=341;z=1;right=216;cls="button" };
btnPathText={ bottom=374;text=
"GDI+ 路径文字";left=312;top=341;z=2;right=460;cls="button" }
)
/*}}*/

import gdip;//导入GDI+库

winform.btnPathText.oncommand =
function(id,event){

   
//图形对象graphics(可以看作是画板)
    var Graphics = gdip.graphics(winform)
   
   
//加上抗锯齿功能
    Graphics.smoothingMode = 4/*_GdipSmoothingModeAntiAlias*/ ;
   
   
//创建画笔,画笔pen只能画一个轮廓(画线)
    var re,Pen = gdip.CreatePen1( 0xFF222222, 2,2/*_GdipUnitPixel*/ );
   
   
//创建刷子,画刷可以对一个东西进行填充(刷子)。
    var re,Brush = gdip.CreateSolidFill(0xFFDEDEDE);
      
     
   
//创建FontFamily
    family = gdip.family( "Verdana"  );
   
   
//创建stringFormat
    strformat = gdip.stringformat ( );
   
//设置样式
    strformat.align = 0/*_GdipStringAlignmentNear*/;  
     
   
//设置文字区域
    rclayout = ::RECT(10,10,500,150);
   
   
//创建一个文字路径
    path = gdip.path( 0/*_GdipFillModeAlternate*/ );

   
//添加文字到上面创建的路径中
    path.addstringI( "aardio", family, 1/*_GdipFontStyleBold*/, 55, rclayout, strformat);
   
   
/* ***********************************************
     * GDI+中一般以I结尾的函数,参数使用int类型,而非I结尾的函数,参数使用float类型
     * 这里的rclayout就是普通的int类型参数组成的RECT结构体
     * ***********************************************
    */

   
   
//fillPath填充路径
    Graphics.fillPath( Brush, path)
     
   
//drawPath描边
    Graphics.drawPath( Pen, path)
     

   
//删除所有GDI+对象  
    gdip.DeleteBrush(Brush);
    gdip.DeletePen(Pen);
     
    strformat.delete();
    family.delete();
    path.delete();
   
}
//endproc


winform.btnDrawString.oncommand =
function(id,event){
   
//图形对象graphics(可以看作是画板)
    var graphics = gdip.graphics(  winform )
   
   
//创建刷子
    var re,Brush = gdip.CreateSolidFill(0xFFFF0000);
   
   
//创建FontFamily
    var family = gdip.family("隶书");
   
   
//创建stringFormat
    var strformat = gdip.stringformat ( );
   
//设置样式
    strformat.align = 0/*_GdipStringAlignmentNear*/;
   
   
//创建Font
    var curFont = family.createFont(  15,2/*_GdipFontStyleItalic*/, 2/*_GdipUnitPixel*/)
   
   
//设置文字抗据齿
    graphics.textRenderingHint = 3/*_GdipTextRenderingHintAntiAliasGridFit*/;

   
//设置文字区域
    rclayout = gdip.RECTF();
    rclayout.left = 15
    rclayout.top = 15
    rclayout.right = 500
//在这里指的是宽度
    rclayout.bottom = 150 //在这里指的是高度
     
    graphics.drawString(
"Hellow world! 这是我们第一个GDI+文字~!!"  , curFont, rclayout, strformat,Brush);
   
/* ***********************************************
     * GDI+中一般以I结尾的函数,参数使用int类型,而非I结尾的函数,参数使用float类型
     * 这里的rclayout就是float类型参数组成的RECTF结构体
     * ***********************************************
    */

   
   
//删除所有GDI+对象  
    gdip.DeleteFont(curFont);
    gdip.DeleteBrush(Brush);
   
    strformat.delete();
    family.delete();

}
//endproc

winform.show(
true)
win.loopMessage();

return winform;

评分

参与人数 1 +200 +200 收起 理由
JacenHe + 200 + 200 很给力!

查看全部评分

13

主题

92

回帖

719

积分

三级会员

积分
719
QQ
发表于 2012-11-12 15:57:00 | 显示全部楼层
这个是whhtp简单应用
模式匹配简单应用
  1. import fsys;
  2. import inet.whttp;
  3. import process;
  4. url="http://baike.baidu.com/view/47227.htm"
  5. headers=""

  6. whttp = inet.whttp()

  7. html=whttp.get(url,headers)
  8. import console
  9. //console.log(html)
  10. regexExpression="教材中,(.*?)总是"
  11. for strGmatchResult in string.gmatch( html, regexExpression ){
  12. console.log(strGmatchResult)
  13. }
复制代码

评分

参与人数 1 +200 +200 收起 理由
JacenHe + 200 + 200 很给力!

查看全部评分

5

主题

67

回帖

468

积分

二级会员

积分
468
发表于 2012-11-12 16:20:58 | 显示全部楼层
  1. import win.ui;
  2. /*DSG{{*/
  3. mainForm = ..win.form( bottom=168;parent=...;text="aardio Form";right=523 )
  4. mainForm.add(
  5. button={ bottom=132;right=364;left=173;top=106;z=1;text="确定";cls="button" };
  6. static={ bottom=67;right=184;left=66;top=44;z=2;transparent=1;text="请输入你的名字:";cls="static" };
  7. edit={ bottom=66;right=366;left=168;multiline=1;top=38;z=3;edge=1;cls="edit" }
  8. )
  9. /*}}*/

  10. mainForm.button.oncommand = function(id,event){
  11.         mainForm.msgbox( mainForm.edit.text+"你好,欢迎使用aardio来到编程世界!" );//弹出对话框       
  12. }
  13. mainForm.show()
  14. win.loopMessage();
复制代码

9

主题

36

回帖

1万

积分

九级会员

积分
17739
发表于 2012-11-12 16:47:17 | 显示全部楼层
import console;
console.log("hello world");

评分

参与人数 1 +50 +50 收起 理由
JacenHe + 50 + 50 很给力!

查看全部评分

50

主题

226

回帖

1679

积分

荣誉会员

积分
1679
发表于 2012-11-12 17:26:50 | 显示全部楼层
import process
import winex

str =
"Hello World !"

process.execute_waitInput(
"notepad.exe")
hwnd = winex.findActivate(
"无标题")

for(i=1;#str;1){
    winex.sendString(str[[ i ]], hwnd)
   
sleep(200)
}

winex.sendString(
'\r\n\r\n\t\t aardioaardio bbs.aardio.com ', hwnd)

评分

参与人数 1 +300 +300 收起 理由
JacenHe + 300 + 300 很给力!

查看全部评分

4

主题

17

回帖

142

积分

一级会员

积分
142
发表于 2012-11-12 18:25:21 | 显示全部楼层
import console; //打开控制台窗口

//定义一个类
class cs{
    a = 123;
}  

//每一个类拥有独立的名字空间,名字空间中的变量也就是类的公用静态成员。
cs.hello = "这是hello";
d = cs();
//创建新对象
console.log( "d.a" , d.a ) //显示123
console.log( "cs.hello" , cs.hello) //显示"类的静态成员hello";

//定义一个类
class cls{
    k=123;
}
cls.world=
"这是world";
g =cls();
//创建新对象
console.log("g.world",g.world)//显示123
console.log( "cls.world" , cls.world) //显示"类的静态成员worid";

评分

参与人数 1 +100 +100 收起 理由
JacenHe + 100 + 100 很给力!

查看全部评分

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

手机版|未经许可严禁引用或转载本站文章|aardio.com|aardio 官方社区 ( 皖ICP备09012014号 )

GMT+8, 2026-9-8 00:14 , Processed in 0.084927 second(s), 31 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表