主頁 > 知識庫 > hello world程序集錦

hello world程序集錦

熱門標簽:南召400電話辦理資費 福建ai電銷機器人加盟公司 去哪里辦卡 揭陽外呼系統(tǒng)公司 鄭州中國移動400電話申請 無錫電銷機器人銷售 招聘信息 地圖標注植物名稱 地圖標注審核工作怎么樣注冊 熱血傳奇沃瑪森林地圖標注

hello world作為所有編程語言的起始階段,占據著無法改變的地位,所有中/英/法/德/美……版本的編程教材中,hello world總是作為第一個TEST記錄于書本之中,所有的編程第一步就在于此了!經典之中的經典!

hello world!

"Hello, world"程序是指在計算機屏幕上輸出Hello, world這行字符串的計算機程序,“hello, world”的中文意思是“世界,你好”。這個例程在Brian Kernighan和Dennis M. Ritchie合著的The C Programming Language中被使用而廣泛流行。因為它的簡潔、實用,并包含了一個程序所應具有的一切,因此為后來的編程類圖書的作者提供了范例,一直待續(xù)到今。

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 ATT、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操作系統(tǒng)

[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

傳統(tǒng)版 BASIC(例如 GWBASIC):

10 PRINT "Hello, world!"
20 END

或在提示符輸入:

? "Hello, world!"

現(xiàn)代版 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

#include stdio.h>

int main(void)
{
 printf("Hello, world!\n");
 return 0;
}

或者:

#include stdio.h>
int main(void)
{
 puts("Hello, world!");
 return 0;
}

C++

#include iostream>

int main()
{
 std::cout  "Hello, world!"  std::endl;
 return 0;
}

或者:

#include iostream>
using 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 World

!-- 或者 -->

html>
head>
title> Hello World /title>
/head>
body>
Hello World
/body>
/html>

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[]{"h1>Hello, World!/h1>"}); // h1>Hello, World!/h1>
 app.invoke("say", new Object[]{"h2>Bye!/h2>"});   // h2>Bye!/h2>

 // 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@@>}=M:9wv6WsU2T|nm-,jcL(I%$#"
 `CB]V?TxuVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>

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!'
.>

OCaml

let main () =
 print_endline "Hello world!";;

Pascal

program Hello;{此行可以省略}
begin
 writeln('Hello, world!');
end.

Perl

#!/usr/bin/env perl
print "Hello, world!\n";

Perl 5.10(含)以后版本:

#!/usr/bin/env perl
use 5.010;
say "Hello, world!";

PHP

?php
 echo 'Hello, world!';//通常使用這個,比 print 少一個字元
 print 'Hello, world!';
?>
或者

?= "Hello World!"?>

Pike

#!/usr/local/bin/pike
int main()
{
 write("Hello, world!\n");
 return 0;
}

PL/I

Test: procedure options(main);
 declare My_String char(20) varying initialize('Hello, world!');
 put skip list(My_String);
end Test;

Prolog

goal
 write("hello,world!").

Python

適用于Python 2:

#!/usr/bin/env python
print "Hello, world!"
適用于Python 3:

#!/usr/bin/env python
print("Hello, world!")

REXX

say "Hello, world!"

Ruby

#!/usr/bin/ruby
puts "Hello, world!"

Sbyke Laborana

INIT min:1001
Om:"Hello, world!"

Scheme

(display "Hello, world!")
(newline)

sed

(需要至少一行輸入)

sed -ne '1s/.*/Hello, world!/p'

Seed7

$ include "seed7_05.s7i";

 const proc: main is func
 begin
  writeln("Hello, world!");
 end func;

Smalltalk

Transcript show: 'Hello, world!'

Small Basic

TextWindow.WriteLine("Hello, world!")

SNOBOL

OUTPUT = "Hello, world!"
END

SQL

第一種

CREATE TABLE MESSAGE (TEXT CHAR(15));
INSERT INTO MESSAGE (TEXT) VALUES ('Hello, world!');
SELECT TEXT FROM MESSAGE;
DROP TABLE MESSAGE;
第二種

SELECT 'hello, world';
第三種

print 'hello,world!'

Tcl

#!/usr/local/bin/tcl
puts "Hello, world!"

TScript

? "Hello, world!"

Turing

put "Hello, world!"

UNIX-style shell

程序中的/bin/sh可改為您使用的shell

#!/bin/sh
echo 'Hello, world!'

bc

 #!/usr/bin/bc -q
print "Hello World"
quit

dc

#!/usr/bin/env dc [Hello World]p

GUI

Delphi

program HelloWorld;
uses
 Dialogs;
begin
 ShowMessage('Hello, World!');
end.

Nuva

.
 System.Ui.ShowMessage('Nuva', 'Hello, world!', ['OK'])
.>

Visual Basic

MsgBox "Hello, world!"
或者

Print "Hello, world!"

Visual FoxPro

? "Hello, world!"

X11

用一個程序

xmessage 'Hello, world!'

使用Qt

#include QApplication>
#include QLabel>

int main(int argc, char *argv[])
{
 QApplication app(argc, argv);
 QLabel label("Hello, world!");
 label.show();
 return app.exec();
}

C 和 GTK+

#include gtk/gtk.h>

int main(int argc, char * args[])
{
 GtkWidget * win, * label;
 gtk_init( argc,  args);

 label = gtk_label_new("Hello, world!");
 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_container_add(GTK_CONTAINER(win), label);
 gtk_widget_show_all();

 gtk_main();

 return 0;
}

用C++和gtkmm 2

#include iostream>
#include gtkmm/main.h>
#include gtkmm/button.h>
#include gtkmm/window.h>
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::slot(*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);
}

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(g);
  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);
 }
}

Java Applet

Java Applet用于HTML文件。

HTML代碼:

html>
head>
title>Hello World/title>
/head>
body>
HelloWorld Program says:
applet code="HelloWorld.class" width="600" height="100">
/applet>
/body>
/html>

Java代碼:

import java.applet.*;
import java.awt.*;

public class HelloWorld extends Applet 
{
 public void paint(Graphics g) 
 {
  g.drawString("Hello, world!", 100, 50);
 }
}

JavaScript

JavaScript是一種腳本語言。最廣泛用于HTML文件中,也可以用在其它宿主環(huán)境下,比如Microsoft Windows 腳本宿主(WSH)和一些Web服務環(huán)境。

用于HTML中:

alert("Hello, World!");
//或者
document.write("Hello, World!");

用于WSH中:

WScript.Echo("Hello, World!");

PostScript

PostScript是一種專門用來創(chuàng)建圖像的語言,常用于打印機。

/font /Courier findfont 24 scalefont
font setfont
100 100 moveto
(Hello World!) show
showpage

XAML

Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="XAMLSample.Page1"
>
Button Click="HelloWorld" Name="Button1">Click Here/Button>
/Page>

using System;
using System.Windows;
using System.Windows.Controls;

namespace XAMLSample
{
 public partial class Page1 : Page
 {
  void HelloWorld(object sender, RoutedEventArgs e)
  {
   MessageBox.Show("Hello, world!");
  }
 }
}

易語言

 .版本 2
.程序集 窗口程序集1
.子程序 __啟動窗口_創(chuàng)建完畢
信息框

(“Hello, World!”, 0, )

您可能感興趣的文章:
  • Android 初識 Helloworld 詳解
  • 全民學編程之 Hello World
  • 從零學Python之hello world
  • Cocos2d-x中調用Lua及HelloWorld.lua源碼分解
  • Go語言hello world實例
  • AngularJS入門教程之Hello World!
  • 使用angular寫一個hello world

標簽:景德鎮(zhèn) 桂林 鹽城 黔南 南昌 宣城 文山 東莞

巨人網絡通訊聲明:本文標題《hello world程序集錦》,本文關鍵詞  hello,world,程序,集錦,hello,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《hello world程序集錦》相關的同類信息!
  • 本頁收集關于hello world程序集錦的相關信息資訊供網民參考!
  • 推薦文章