您现在的位置是:网站首页> 编程资料编程资料
hello world程序集锦_其它综合_
2023-05-27
342人已围观
简介 hello world程序集锦_其它综合_
hello world作为所有编程语言的起始阶段,占据着无法改变的地位,所有中/英/法/德/美……版本的编程教材中,hello world总是作为第一个TEST记录于书本之中,所有的编程第一步就在于此了!经典之中的经典!
hello world!
"Hello, world"程序是指在计算机屏幕上输出Hello, world这行字符串的计算机程序,“hello, world”的中文意思是“世界,你好”。这个例程在Brian Kernighan和Dennis M. Ritchie合著的The C Programming Language中被使用而广泛流行。因为它的简洁、实用,并包含了一个程序所应具有的一切,因此为后来的编程类图书的作者提供了范例,一直待续到今。
hello world程序全集
ActionScript
trace("Hello, world!");
Ada
with TEXT_IO; procedure HELLO is begin TEXT_IO.PUT_LINE ("Hello, world!"); end HELLO;
汇编语言
x86 CPU,GNU/Linux,NASM
section .data msg db 'Hello, world!',0xA len equ $-msg section .text global _start _start: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 mov ebx,0 mov eax,1 int 0x80
x86 AT&T、Gas
.data msg : .string "Hello, world!\n" len = . - msg .text .global _start _start: movl $len, %edx movl $msg, %ecx movl $1 , %ebx movl $4 , %eax int $0x80 movl $0 , %ebx movl $1 , %eax int $0x80
x86 CPU、Windows、MASM32
.386 .model flat,stdcall option casemap:none ;========================================================== include windows.inc include user32.inc includelib user32.lib include kernel32.inc includelib kernel32.lib ;========================================================== .data szCaption db "A MessageBox!", 0 szText db "Hello, world!", 0 ;========================================================== .code start: invoke MessageBox, NULL, addr szText, addr szCaption, MB_OK invoke ExitProcess, NULL ;========================================================== end start
8086操作系统
[BITS 16] org 0x7c00 mov ax,cs mov ds,ax mov es,ax call DispStr jmp $;End Hear DispStr: mov ax, BootMessage mov bp, ax mov cx, 16;How long is the String mov ax, 0x1301 mov bx, 0x000c mov dl, 0 int 0x10 ret BootMessage: db "Hello, world!" times 510-($-$$) db 0x0 dw 0xaa55; Bootable Mark
ASP
<% Response.Write("Hello, world!") %>
或者简单地写成:
<%= "Hello, world!" %>
AutoIt
MsgBox(1,'','Hello, world!')
AWK
BEGIN { print "Hello, world!" } Bash (or sh) echo 'Hello, world!'
或者:
printf 'Hello, world!\n'
BASIC
传统版 BASIC(例如 GWBASIC):
10 PRINT "Hello, world!" 20 END
或在提示符输入:
? "Hello, world!"
现代版 BASIC(例如 Quick BASIC):
PRINT "Hello, world!"
以下的语句,在 Quick BASIC 中同样有效:
? "Hello, world!"
BCPL
GET "LIBHDR" LET START () BE $( WRITES ("Hello, world!*N") $)
Brainfuck
++++++++++[>+++++++>++++++++++>+++>+<<<<-] >++.>+.+++++++..+++.>++.<<+++++++++++++++. >.+++.------.--------.>+.>.
BlitzBasic
Print "Hello, world!" WaitKey
BOO
print "Hello, world!"
C
#includeint main(void) { printf("Hello, world!\n"); return 0; }
或者:
#includeint main(void) { puts("Hello, world!"); return 0; }
C++
#includeint main() { std::cout << "Hello, world!" << std::endl; return 0; }
或者:
#includeusing namespace std; int main() { cout << "Hello, world!" << endl; return 0; }
C++/CLI
int main() { System::Control::WriteLine("Hello, world!"); }
C# (C Sharp)
class HelloWorldApp { static void Main(string[] args) { System.Console.WriteLine("Hello, world!"); } }
或者(仅用于Microsoft Windows)
class HelloWorldApp { [DllImport("user32.dll")] static extern MessageBox(string title, string message); public static void Main() { MessageBox(null, "Hello, world!"); } }
或者(使用附加的Windows Forms)
using System.Windows.Forms; class HelloWorldApp { public static void Main() { MessageBox.Show("Hello, world!"); } }
COBOL
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. DISPLAY "Hello, world!". STOP RUN.
Common Lisp
;直接输出 "Hello world!"
;或者
(format t "Hello world!~%")
DOS批处理
@echo Hello, world!
对于MS-DOS 3.0或更低版本:
echo off cls echo Hello, world!
Linux Shell
echo 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!\n").
Forth
." Hello, world!" CR
Fortran
WRITE(*,*) 'Hello, world!' STOP END
HTML
Hello WorldHello World Hello World
HQ9+
H INTERCAL PLEASE DO ,1 <- #13 DO ,1 SUB #1 <- #238 DO ,1 SUB #2 <- #112 DO ,1 SUB #3 <- #112 DO ,1 SUB #4 <- #0 DO ,1 SUB #5 <- #64 DO ,1 SUB #6 <- #238 DO ,1 SUB #7 <- #26 DO ,1 SUB #8 <- #248 DO ,1 SUB #9 <- #168 DO ,1 SUB #10 <- #24 DO ,1 SUB #11 <- #16 DO ,1 SUB #12 <- #158 DO ,1 SUB #13 <- #52 PLEASE READ OUT ,1 PLEASE GIVE UP
Java
public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } }
or in tinystruct2.0:
package tinystruct.examples; import org.tinystruct.AbstractApplication; import org.tinystruct.Application; import org.tinystruct.ApplicationException; import org.tinystruct.system.ApplicationManager; public class hello extends AbstractApplication { @Override public void init() { // TODO Auto-generated method stub this.setAction("say", "say"); } @Override public String version() { // TODO Auto-generated method stub return null; } public String say(String words){ System.out.println(words); return words; } /** * @param args * @throws ApplicationException */ public static void main(String[] args) throws ApplicationException { // TODO Auto-generated method stub // Praise to the Lord! ApplicationManager.install(new hello()); // to print 'Hello World' ApplicationManager.call("say/Hello World", null); // Hello World // or... Application app=ApplicationManager.get( hello.class.getName()); app.invoke("say", new Object[]{"Hello, World!
"}); //Hello, World!
app.invoke("say", new Object[]{"Bye!
"}); //Bye!
// or... // http://localhost:8080/?q=say/Hello World // https://github.com/m0ver/tinystruct2.0 } }
JSP
<% out.print("Hello, world!"); %> 或者简单地写成: <%="Hello, world!"%>
Lisp
;直接输出 "hello, world" ;或者 (format t "hello, world~%")
Lua
print "Hello, world!"
Malbolge
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=
Metapost
beginfig(1); draw (0,0)--(0,10); draw (0,5)--(5,5); draw (5,0)--(5,10); draw (12,0)--(7,0)--(7,10)--(12,10); draw (12,5)--(7,5); draw (14,10)--(14,0)--(19,0); draw (21,10)--(21,0)--(26,0); draw (28,5)...(30.5,0)...(33,5)...(30.5,10)...cycle; draw (38,10)--(39.25,0)--(40.5,10)--(41.75,0)--(43,10); draw (45,5)...(47.5,0)...(50,5)...(47.5,10)...cycle; draw (52,0)--(52,10); draw (52,10)..(57,4)..(52,6.5); draw (52,5)--(57,0); draw (61,10)--(61,0)--(66,0); draw (68,10)--(68,0)..(73,5)..cycle; endfig; end
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
Nuva
<..直接输出..> Hello, world! <..或者..><. // 不带换行 ? "Hello, world!" // 或者 // 带换行 ?? 'Hello, world!' .><
点击排行
本栏推荐
