词条 | hello world |
释义 | hello world作为所有编程语言的起始阶段,占据着无法改变的地位,所有中/英/法/德/美……版本的编程教材中,hello world总是作为第一个TEST记录于书本之中,所有的编程第一步就在于此了!经典之中的经典!hello world! 基于控制台(RPGLE语言 AAuto语言 Ada语言 AmigaE语言 APL语言 Assembly语言 AWK语言 BASIC语言 MS BASIC语言 TI-BASIC语言 Structured BASIC语言 BCPL语言 BF语言 C语言 C++语言 C#语言 Clean语言 CLIST语言 COBOL语言 Common Lisp语言 Delphi 语言 Eiffel语言 Erlang语言 Forth语言 Fortran语言 Google Go语言 Haskell语言 Iptscrae语言 Java语言 Logo语言 Lua语言 MIXAL语言 MSDOS batch语言 OCaml语言 Pascal语言 Perl语言 PHP语言 Pike语言 PL/I语言 Python语言 REXX语言 Ruby语言 Sather语言 Scheme语言 Sed语言 Self语言 Smalltalk语言 SML语言 SNOBOL语言 SQL语言(1) StarOffice Basic语言 Tcl语言 Turing语言 UNIX-style shell语言 Romanian pseudocode语言) 基于传统图形界面(Autoit C++ bindings for GTK graphics toolkit Java语言 QApplication app语言 Visual Basic语言 易语言 O语言 Windows API (in C)语言) 基于Web语言(Java applet语言 JavaScript(输入浏览器地址栏) ASCII语言 HTML语言 PostScript语言 TeX语言 LaTeX语言 GML语言 Javascript语言) hello world程序简介这个例程是从Kernighan & Ritchie 合著的《The C Programme Language》开始有的,因为它的简洁,实用,并包含了一个程序所应具有的一切,因此为后来的些类书的作者提供了范例,一直待续到今。最初的hello world有个传统,即全小写,有逗号,且逗号后空一格,也就是:hello, world 无感叹号。但如今已不再被遵守。 hello world 的第一版: main(){ printf("hello, world\"); } 我们刚开始接触计算机语言大多从Hello world 开始,下面是各种语言的Hello world program: 基于控制台RPGLE语言D Vc_Hello s 100A C Eval Vc_Hello = 'Hello World!' C DSPLY Vc_Hello AAuto语言io.open();//打开控制台 io.print("Hello world!") execute("pause") //按任意键继续 io.close();//关闭控制台 ABC语言 WHILE (1=1) : WRITE "Hello World " Ada语言with Ada.Text_Io; use Ada.Text_Io; procedure Hello is begin Put_Line ("Hello, world!"); end Hello; AmigaE语言PROC main() WriteF('Hello, World!') ENDPROC APL语言'Hello World' Assembly语言Accumulator-only architecture: DEC PDP-8, PAL-III assembler See the Example section of the PDP-8 article. Accumulator + index register machine: MOS 6502, CBM, ca65 asm MSG: .ASCIIZ "Hello, world!" LDX #0 LDA MSG,X ; load initial char @LP: JSR $FFD2 ; CHROUT CBM KERNAL INX LDA MSG,X BNE @LP RTS Accumulator/Index microcoded machine: Data General Nova, RDOS See the example section of the Nova article. Expanded accumulator machine: Intel x86, MS-DOS, TASM MODEL SMALL IDEAL STACK 100H DATASEG MSG DB 'Hello, world!$' CODESEG MOV AX, @data MOV DS, AX MOV DX, OFFSET MSG MOV AH, 09H ; DOS: output ASCII$ string INT 21H MOV AX, 4C00H INT 21H END General-purpose-register CISC: DEC PDP-11, RT-11, MACRO-11 .MCALL .REGDEF,.TTYOUT,.EXIT .REGDEF HELLO: MOV #MSG,R1 MOVB (R1),R0 LOOP: .TTYOUT MOVB +(R1),R0 BNE LOOP .EXIT MSG: .ASCIZ /HELLO, WORLD!/ .END HELLO CISC: VAX, VMS, MACRO32 .title hello term_name: .ascid /SYS$INPUT/ term_chan: .blkw 1 out_iosb: .blkq 1 msg: .asciz /Hello, world!/ .entry start,0 ; establish a channel for terminal I/O $assign_s devnam=term_name,- chan=term_chan blbc r0,error ; queue the I/O request $qio_s chan=term_chan,- func=#io$_writevblk,- iosb=out_iosb,- p1=msg,- p2=#13 blbc r0,error $exit_s ; normal exit error: halt ; error condition .end start AWK语言BEGIN { print "Hello, world!" } BASIC语言PRINT "HELLO WORLD" MS BASIC语言(traditional, unstructured) 10 PRINT "Hello, world!" 20 END TI-BASIC语言isp "Hello, world!" Structured BASIC语言print "Hello, world!" BCPL语言GET "LIBHDR" LET START () BE $( WRITES ("Hello, world!*N") $) BF语言++++++++++[>+++++++>++++++++++>+++>+<<<<-] >++.>+.+++++++..+++.>++.<<+++++++++++++++. >.+++.------.--------.>+.>. C语言#include <stdio.h> int main(void) { printf("Hello, world!\"); return 0; } C++语言#include <iostream> using namespace std; int main() { cout << "Hello, world!" << endl; return 0; } C#语言using System; class HelloWorldApp { public static void Main() { Console.WriteLine("Hello world!"); } } Clean语言module hello Start :: String Start = "Hello, world" CLIST语言PROC 0 WRITE Hello, World! COBOL语言IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. DISPLAY "Hello, world!". STOP RUN. Common Lisp语言(format t "Hello world!~%") Delphi 语言ShowMessage('hello World!'); Eiffel语言class HELLO_WORLD creation make feature make is local io:BASIC_IO do !!io io.put_string("%N Hello, world!") end -- make end -- class HELLO_WORLD Erlang语言-module(hello). -export([hello_world/0]). hello_world() -> io:fwrite("Hello, world!\"). Forth语言." Hello, world!" CR Fortran语言PROGRAM HELLO WRITE(*,10) 10 FORMAT('Hello, world!') STOP END Google Go语言package main import "fmt" func main() { fmt.Println("Hello, world!") } Haskell语言module HelloWorld (main) where main = putStr "Hello World\" Iptscrae语言ON ENTER { "Hello, " "World!" & SAY } Java语言public class Example{ public static void main(String[] args) { System.out.println("Hello, world!"); } } Logo语言print [hello world!] Lua语言print "Hello, world!" MIXAL语言TERM EQU 19 the MIX console device number ORIG 1000 start address START OUT MSG(TERM) output data at address MSG HLT halt execution MSG ALF "MIXAL" ALF " HELL" ALF "O WOR" ALF "LD " END START end of the program MSDOS batch语言@echo off echo Hello, world! OCaml语言let _ = print_endline "Hello world!";; OPL PROC hello: PRINT "Hello, World" ENDP Pascal语言program hello_world; begin writeln('Hello World!'); end. Perl语言print "Hello, world!\"; PHP语言<?php print("Hello, world!"); ?> 或者: <?php echo("Hello, world!"); Pike语言#!/usr/local/bin/pike int main() { write("Hello, world!\"); return 0; } PL/I语言Test: procedure options(main); declare My_String char(20) varying initialize('Hello, world!'); put skip list(My_String); end Test; Python语言print "Hello, world!" REXX语言also NetRexx and Object REXX say "Hello, world!" Ruby语言print "Hello, world!\" Sather语言class HELLO_WORLD is main is #OUT+"Hello World\"; end; end; Scheme语言(display "Hello, world!") (newline) Sed语言(requires at least one line of input) sed -ne '1s/.*/Hello, world!/p' Self语言'Hello, World!' uppercase print. Smalltalk语言Transcript show: 'Hello, world!' SML语言print "Hello, world!\"; SNOBOL语言OUTPUT = "Hello, world!" END SQL语言(1)数据库操作版 create table MESSAGE (TEXT char(15)); insert into MESSAGE (TEXT) values ('Hello, world!'); select TEXT from MESSAGE; drop table MESSAGE; 简单版 print 'Hello, World.' StarOffice Basic语言sub main print "Hello, World" end sub Tcl语言puts "Hello, world!" Turing语言put "Hello, world!" UNIX-style shell语言echo 'Hello, world!' Romanian pseudocode语言(UBB Cluj-Napoca)Algoritmul Salut este: fie s:="Hello, world"; tipareste s; sf-Salut 基于传统图形界面Autoitguicreate("hello, word") guisetstate() msgbox(48,"test","hello, word") while guigetmsg()+3 wend C++ bindings for GTK graphics toolkit#include #include #include #include using namespace std; class HelloWorld : public Gtk::Window { public: HelloWorld(); virtual ~HelloWorld(); protected: Gtk::Button m_button; virtual void on_button_clicked(); }; HelloWorld::HelloWorld() : m_button("Hello, world!") { set_border_width(10); m_button.signal_clicked().connect(SigC:lot(*this, &HelloWorld::on_button_clicked)); add(m_button); m_button.show(); } HelloWorld::~HelloWorld() {} void HelloWorld::on_button_clicked() { cout << "Hello, world!" << endl; } int main (int argc, char *argv[]) { Gtk::Main kit(argc, argv); HelloWorld helloworld; Gtk::Main::run(helloworld); return 0; } Java语言import java.awt.*; import java.awt.event.*; public class HelloFrame extends Frame { HelloFrame(String title) { super(title); } public void paint(Graphics g) { super.paint; java.awt.Insets ins = this.getInsets(); g.drawString("Hello, world!", ins.left + 25, ins.top + 25); } public static void main(String args []) { HelloFrame fr = new HelloFrame("Hello"); fr.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit( 0 ); } } ); fr.setResizable(true); fr.setSize(500, 100); fr.setVisible(true); } } Qt toolkit (in C++) #include #include #include #include class HelloWorld : public QWidget { Q_OBJECT QApplication app语言(argc, argv); HelloWorld helloWorld; app.setMainWidget(&helloWorld); helloWorld.show(); return app.exec(); } Visual Basic语言1.信息框 MsgBox "Hello, world!" 2.输出到窗体 Print "Hello, world!" 易语言窗体程序: .子程序 __启动窗口_创建完毕 信息框 (“Hello, world!”, 0, ) 控制台程序: .版本 2 .程序集 程序集1 .子程序 _启动子程序, 整数型, , 本子程序在程序启动后最先执行 标准输出 (, “Hello World!”) ' 输出Hello World 标准输入 () ' 达到暂停程序的效果以便于查看Hello World 返回 (0) ' 可以根据您的需要返回任意数值 O语言O汇编语言 .包含文<*oasm32.oah> .包含文<*user32.oah> .包含文<*kernel32.oah> .引用库<*user32.lib> .引用库<*kernel32.lib> .代码段 { 入口 主函数() { 提示框(0,&"Hello, world!",&"hello world!",0) 退出进程(0); } } O中间语言 .包含文<*视窗32.omh> 入口 主函数() { 提示框(0,取地址 "Hello world!",取地址 "",0); 退出进程(0); } Windows API (in C)语言#include LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); char szClassName[] = "MainWnd"; HINSTANCE hInstance; int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASSEX wincl; hInstance = hInst; wincl.cbSize = sizeof(WNDCLASSEX); wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.style = 0; wincl.hInstance = hInstance; wincl.lpszClassName = szClassName; wincl.lpszMenuName = NULL; //No menu wincl.lpfnWndProc = WindowProcedure; wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); //Color of the window wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor if (!RegisterClassEx(&wincl)) return 0; hwnd = CreateWindowEx(0, //No extended window styles szClassName, //Class name "", //Window caption WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top positions of the window 120, 50, //Width and height of the window, NULL, NULL, hInstance, NULL); //Make the window visible on the screen ShowWindow(hwnd, nCmdShow); //Run the message loop while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); TextOut(hdc, 15, 3, "Hello, world!", 13); EndPaint(hwnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } 基于Web语言Java applet语言Java applets work in conjunction with HTML files. HelloWorld Program says: import java.applet.*; import java.awt.*; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello, world!", 100, 50); } } JavaScript(输入浏览器地址栏)javascript:alert('Hello, world!') 文档格式: ASCII语言The following sequence of characters, expressed in hexadecimal notation (with carriage return and newline characters at end of sequence): 48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0D 0A HTML语言<HTML> <body> <p>Hello, world!</p> </body> </HTML> PostScript语言/font /Courier findfont 24 scalefont font setfont 100 100 moveto (Hello world!) show showpage TeX语言\\font\\HW=cmr10 scaled 3000 \\leftline{\\HW Hello world} \\bye LaTeX语言\\documentclass{article} \\begin{document} Hello, world! \\end{document} GML语言draw_text ( 0 , 0 , "Hello World") Javascript语言<script language="javascript"> alert('hello world!'); </script> C语言Hello World 详解下面是C语言 hello world 的源代码 . #include "stdio.h" intmain(int argc,char** argv) { printf("hello world!"); return0; } 以下为详解: #include 表示将一个文件包含到源代码文件中. 第一行的代码表示将stdio.h文件包含到源代码文件中,stdio.h文件包含各种库函数的申明,其中一个就是很重要的输出函数printf. int 是个数据类型申明,在C语言中为整型数据.在int main中表示,main函数的返回值为整型. main表示一个函数,这个函数为C语言程序的入口函数,所以执行代码都是从main函数开始的.所以main函数为C语言的主函数.如是一个程序没有main,则最后编译连接时,会提示没有main函数. 在(int argc,char** argv)中,表示main函数有两个参数,一个为int整型,一个为char** . char** 是一个指针类型,它指向一个字符串数据.(此内容比较高级,略过.).C程序运行时,用户可以向程序传递一些参数,参数以字符串的形式都保存在argv中,每个参数都以空格分割,argc记录着参数的个数.如果没有传递参数,则系统也会把字符串形式的程序名当做参数传递给程序.所以,argc的值大于等于1. printf是C语言中最常用的格式化输出函数.用户通过向printf函数传递各种参数,然后转化成字符串,最终在命令行上输出. return 0;用来在函数要退出时,返回给函数的调用者一个值.main函数为程序的入口主函数.调用它的人一般是操作系统,所以在程序退出时,返回一个值给系统.这里返回一个0,一般情况下,意思不大.习惯上,如果程序执行正确,返回一个0,错误则返回1,或者-1什么的.C程序中有各种各样的函数,每个函数之间互相通信,为了知道函数的执行情况,都要返回一个值给调用者. Lady Antebellum单曲简介歌名:Hello World 你好世界;别来无恙 创作:Tom Douglas, Tony Lane, and David Lee 演唱:Lady Antebellum 战前女神;怀旧女郎 所属专辑:《Need You Now》 《想念你》(2009~2010) 专辑发行时间:2010-1-26 专辑发行公司:Capitol Nashville Lady Antebellum 格莱美奖年度专辑《Need You Now》的第四首歌,以希望和生命为主题。主要由男主唱 Charles Kelley 演唱。主要乐器为钢琴。 相信大家对着个组合也并不陌生,可能也有人没听过,听过的人很可能是从Need You Now开始的,是啊,正是这首动听的歌让他们成为格莱美的大赢家。但是笔者偶然间找到一首Hello World,并且找到了这首歌的MV,可能大家也听到过,但是还是忍不住拿来分享,虽然揭示的道理很简单,但是我们真正有几人能做到呢?一首很温暖的曲子,很深刻的歌词,说实话,第一次听歌被感动。这首歌主要是以男主唱来唱的,女主唱只是在最后最多充当和声,这很不同于以往他们的风格,第一次听到男主唱单唱,才发现原来音色是如此的出彩。一开始还有点小惊讶。钢琴为主要伴奏,本来以为只会弹电子琴的键盘手也优雅了一把。说实话这里面的钢琴的确弹得生动,水准不俗。的确要比某些所谓会弹钢琴同志要好许多,这把钢琴弹得的确不是艾薇儿之众比得了的。简直可以说是沁人心脾,直入人心。这首歌的MV拍摄,主唱们并未参与其中,而是以类似旁白的形式进行了边叙。不过说实话还是觉的,主角们在曼哈顿弹唱的画面比较酷,比较拉风。 创作者信息Lady Antebellum (战前女神,怀旧女郎)乡村乐团于2006年在美国田纳西州纳什维尔成立。由Charles Kelley(领队,主唱) Dave Haywood(吉他手,钢琴演奏等)和 HillaryScott(主唱)组成。 2009年8月,团队发行了他们的第四首单曲,“Need You Now”,该首歌曲获得了最热乡村音乐排行榜的第50名,成为他们的第二支第一名单曲。2009年11月28日,第二张专辑《Need You Now》开始制作,并于2010年1月26日正式发行。 第53届格莱美音乐奖的颁奖盛典上,Lady Antebellum 一共拿到了包括年度最佳单曲、年度最佳制作、最佳乡村专辑、最佳乡村组合、最佳乡村歌曲在内的共五个奖项,成为当届格莱美音乐奖获奖最多的音乐人。 歌词Traffic cars, cell phone calls, top video screams at me 往来穿梭的汽车 接连不断的电话 头顶的监控器注视着我 Through my tender window I see a little girl, rust red minivan 透过车窗 我看见 红褐色面包车中的 一位小女孩 She's got chocolate on her face, got little hands 她的脸上沾满了(奶油)巧克力 伸出小手 And she waves at me, yeah, she smiles at me 向我挥舞着 是的 她在朝我微笑 Well, hello world, how've you been? 你好世界 你过得怎样? Good to see you, my old friend 见到你很开心 我的老朋友 Sometimes I feel cold as steel 有时候 我感到 人情冷漠 心如铁石 Broken like I'm never gonna heal 一旦破碎 难以愈合 I see a light, little hope in the little girl 我看见一束光芒 希望 就在小女孩的身上 Well, hello world 你好世界 Every day I drive by a little white church 我每天从教堂旁驱车经过 It's got these little white crosses like angels in the yard 这些白色的十字架就像是院子中的(守护)天使 Maybe I should stop on in and say a prayer 或许我应当停下来 进去 虔诚祷告一番 Maybe talk to God like he is there 或许能够与上帝对话 仿佛他一直都在那里(倾听) Oh, I know He's there, yeah, I know He's there 噢 我知道他(上帝)一定在那 我知道他就在那 Well, hello world, how've you been? 你好世界 你过得怎样? Good to see you, my old friend 见到你很开心 我的老朋友 Sometimes I feel as cold as steel 有时候 我感到 人情冷漠 心如铁石 And broken like I'm never gonna heal 一旦破碎 难以愈合 I see a light, little grace, little faith unfurl 我看见一束光芒(希望) (那是)上帝的恩赐 (那是)信念的绽放 Well, hello world 你好世界 Sometimes I forget what living's for 有时候 我遗忘了生命的意义 And I hear my life through my front door 但我听到了命运在敲打我的心扉 And I'll be there, oh, I'm home again 我就在那里 噢 我再次回到家里(找到心灵的归宿) I see my wife, little boy, little girl 我深情的看着妻子 还有可爱的儿女 Hello world, hello world 你好世界 你好世界 Oh, the empty disappears 噢 内心的空虚失落 全都一扫而光 烟消云散 I remember why I'm here 我想起了自己为何会在此处 To surrender and believe (是)放弃屈服 (还是)执着坚持 I fall down on my knees 我跪倒在上苍面前 Oh hello world, hello world, hello world 噢 你好世界 你好世界 获得荣誉美国BILLBOARD排行榜榜单(2010.11.14-11.20) 排名70 美乡村音乐电视奖年度最佳音乐录影带提名(2010) |
随便看 |
|
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。