各种语言的hello world

各种语言的Hello World程序

1. Ada
===================================
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello World!");
end Hello;

2. ALGOL68
===================================
/‘begin/‘
print("Hello World!")
/‘end/‘

3. AmigaE
===================================
PROC main()
WriteF(/‘Hello World!/‘)
ENDPROC

4. awk
===================================
BEGIN { print "Hello, world!" }

5. BCPL
===================================
GET "LIBHDR"
LET START () BE
$(
WRITES ("Hello, world!*N")
$)

6. Boo
===================================
import System
Console.WriteLine("Hello World!")

7. Brainfuck
===================================
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<
+++++++++++++++.>.+++.------.--------.>+.>.

8. C
===================================
#include <stdio.h>
int main()
{
printf("Hello World!/n");
return 0;
}

9. C++
===================================
#include <iostream.h>
int main()
{
cout<<"Hello World!"<<endl;
return 0;
}

10. Clean
===================================
module hello
Start :: String
Start = "Hello, world"

11. COBOL
===================================
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.

ENVIRONMENT DIVISION.

DATA DIVISION.

PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.

12. Common Lisp
===================================
(format t "Hello world!")

13. D
===================================
import std.c.stdio;
int main(char[][] args)
{
printf("Hello World!/n");
return 0;
}

14. Eiffel
===================================
class HELLO_WORLD
creation
make
feature
make is
local
iBASIC_IO
do
!!io
io.put_string("%N Hello World!")
end -- make
end -- class HELLO_WORLD

15. Erlang
===================================
-module(hello).
-export([hello_world/0]).
hello_world() -> ifwrite("Hello World!/n").

16. Forth
===================================
." Hello World!" CR

17. Fortran
===================================
program Hello
write(*,*) /‘Hello World!/‘
end

18. Haskell
===================================
module HelloWorld (main) where
main = putStr "Hello World!/n"

19. Icon
===================================
procedure main()
write("Hello World!/n")
end

20. 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

21. Iptscrae
===================================
ON ENTER {
"Hello, " "World!" & SAY
}

22. Java
===================================
// 命令行界面:
class Hello
{
public static void main(String ars[])
{
System.out.print("Hello World!/n");
}
}

图形界面:
import java.awt.*;
import java.awt.event.*;
class HelloWorld extends Frame
{
public static void main(String args[])
{
HelloWorld Hello=new HelloWorld();
Label lbl=new Label("Hello World!");
Hello.setTitle("Hello World");
Hello.setSize(300,200);
Hello.setBackground(new Color(224,224,224));
Hello.add(lbl);
lbl.setAlignment(1);
lbl.setFont(new Font("Arial",Font.PLAIN,24));
Hello.setLocation(260,180);
Hello.show();
Hello.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent wet)
{
System.exit(0);
}
});
}
}

23. Lua
===================================
print "Hello World!/n"

24. 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

25. MSIL
===================================
.assembly Hello
{
.ver 1:0:0:0
}
.method public static void main() il managed
{
.entrypoint
.maxstack 1
ldstr "Hello World!/n"
call void [mscorlib]System.Console::Write(class System.String)
ret
}

26. OCaml
===================================
print_endline "Hello world!";;

27. OPL
===================================
PROC hell
PRINT "Hello, World"
ENDP

28. oz
===================================
functor $
import
Application
System
define
{System.print /‘Hello World!/‘}
{Application.exit 0}
end

29. Pascal
===================================
program Hello;
begin
writeln(/‘Hello, world!/‘);
end.

Perl
print "Hello World/n"

30. Pike
===================================
//命令行界面
int main()
{
write("Hello, world!/n");
return 0;
}

//图形界面
int main()
{
GTK.setup_gtk();
GTK.Alert("Hello World!")
->signal_connect("destroy", lambda(){ exit(0); });
return -1;
}

31. PL/I
===================================
Test: procedure options(main);
declare My_String char(20) varying initialize(/‘Hello, world!/‘);
put skip list(My_String);
end Test;

32. PostScript
===================================
/font /Courier findfont 24 scalefont
font setfont
100 100 moveto
(Hello world!) show
showpage

33. PowerBASIC
===================================
#COMPILE EXE
FUNCTION PBMAIN () AS LONG
MSGBOX "Hello World!"
END FUNCTION

34. Prolog
===================================
predicates
Hello
clauses
Hell-
write("Hello World!/n"). %或write("Hello World!"),nl.
goal Hello.

35. Python
===================================
print "Hello World!"

36. Rexx
===================================
say "Hello, world!"

37. Ruby
===================================
print "Hello World!/n"

38. Sather
===================================
class HELLO_WORLD is
main is
#OUT+"Hello World/n";
end;
end;

39. Scheme
===================================
(display "Hello, world!/n")

40. sed
===================================
sed -ne /‘1s/.*/Hello, world!/p/‘

41. Self
===================================
/‘Hello, World!/‘ uppercase print.

42. Smalltalk
===================================
Transcript show: /‘Hello, world!/‘

43. SML
===================================
print "Hello, world!/n";

44. SNOBOL
===================================
OUTPUT = "Hello, world!"
END

45. TCL
===================================
puts "Hello World!"

46. TeX
===================================
/font/HW=cmr10 scaled 3000
/leftline{/HW Hello world}
/bye

47. Turing
===================================
put "Hello, world!"

48. VB
===================================
sub main
msgbox "Hello World!"
end sub

49. VC++
===================================
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="Window";
char lpszTitle[]="Hello World";
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
char Hello[]="Hello World!";
tch(message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 0, 0, Hello,lstrlen(Hello));
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}

50. Win32汇编
===================================
;图形界面Hello World
.386
.model flat, stdcall
option casemap :none
include /masm32/include/windows.inc
include /masm32/include/user32.inc
include /masm32/include/kernel32.inc
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib
.code
start:
jmp @F
szDlgTitle db "Hello World(汇编语言版)",0
szMsg db "Hello World!",0
@@:
push MB_OK
push offset szDlgTitle
push offset szMsg
push 0
call MessageBox
push 0
call ExitProcess
end start

51. 汇编
===================================
.MODEL small
.STACK 100h
.DATA
Hello DB /‘Hello World!/‘,13,10,/‘$/‘
.CODE
mov ax,@data
mov ds,ax
mov ah,9
mov dx,OFFSET Hello
int 21h
mov ah,4ch
int 21h
END

52. ASP
===================================
response.write "Hello World!"

53. C#
===================================
using System;
class Hello
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}

54. FOXBASE
===================================
? "Hello World!"

@0,0 say "Hello World!"

55. Groovy
===================================
print "Hello World!/n"

56. PHP
===================================
echo "Hello World!"

57.VB .MET:
===================================
imports System
module Hello
sub main()
Console.WriteLine("Hello World!")
end sub
end module

58.JScript:
===================================
import System;
Console.Write("Hello World!/n");

print("Hello World!");

59.易语言:
===================================
标准输出 (, “Hello World!”)

信息框 (“Hello World!”, 0, )

60.Delphi:
===================================
program HelloWorld;
uses
Dialogs;
begin
ShowMessage(/‘Hello, World!/‘);
end.

61.DOS Batch:
===================================
@echo Hello World!

62.UNIX Shell
===================================
echo /‘Hello World!/‘

一个没有main方法的Java版Hello World程序:
===================================
class Hello
{
static
{
System.out.println("Hello World!");
System.exit(0);
}
}

63.Xaml:
===================================
<Canvas
xmlns="http://schemas.microsoft.com/2003/xaml"
Background="LightCyan"
Width="100%" Height="100%">
<Text Canvas.Left="90" Canvas.Top="20" FontSize="36">Hello World!</Text>
</Canvas>

64.SQL:
===================================
print /‘Hello World!/‘

65.SML:
===================================
print "Hello World!/n";;

66.Heron:
===================================
program HelloWorld;
functions
{
_main()
{
print_string("Hello, world!");
}
}
End

67.Scala:
===================================
object HelloWorld with Application
{
Console.println("Hello, world!");
}

68.SPARK:
===================================
with Spark_IO;
--# inherit Spark_IO;
--# main_program;
procedure Hello_World
--# global in out Spark_IO.Outputs;
--# derives Spark_IO.Outputs from Spark_IO.Outputs;
is
begin
Spark_IO.Put_Line (Spark_IO.Standard_Output, "Hello World!", 0);
end Hello_World;

69.PureBASIC:
===================================
OpenConsole()
PrintN("Hello World!")
CloseConsole()

MessageRequester("PureBASIC - Hello", "Hello World!", 0)

70.MediaBASIC:
===================================
sub Main()
Console
WriteConsole("Hello World!")
end sub

sub Main()
ShowMessage "Hello World!"
end sub

71.XPB! BASIC:
===================================
Console
PROGRAM
print "Hello World!"

72.Liberty BASIC:
===================================
print "Hello World!"

73.ScriptBASIC:
===================================
print "Hello World!" & chr(13) & chr(10)

74.blassic:
===================================
print "Hello World!"

75.KBASIC:
===================================
Print "Hello World!"

76.Chipmunk BASIC:
===================================
print "Hello World!"

77.BBC BASIC:
===================================
PRINT "Hello World!"

78.Modula-2
===================================
MODULE Hello;
FROM Terminal2 IMPORT WriteLn; WriteString;
BEGIN
WriteString("Hello, world!");
WriteLn;
END Hello;

79.Oberon
===================================
MODULE Hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
PROCEDURE World*;
BEGIN
Texts.WriteString(W, "Hello World!");
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END World;
BEGIN
Texts.OpenWriter(W)
END Hello.

80.VC++ .NET
===================================
#include <stdafx.h>
#using <mscorlib.dll>
using namespace System;
int main()
{
Console::Write("Hello World!/n");
return 0;
}

81.VJ# .NET
===================================
package JHello;
public class Hello
{
public static void main(String[] args)
{
System.out.print("Hello World!/n");

}
}

82.XHTML 1.1
===================================
(Using UTF-8 character set.)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>

83.XUL
===================================
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <box align="center"> <label value="Hello, world!" /> </box> </window>
LaTeX
/documentclass
/begin
Hello, world!
/end
Ruby with WxWidgets
See also TUI section.

require /‘wxruby/‘

class HelloWorldApp < Wx::App
def on_init
ourFrame = Wx::Frame.new(nil, -1, "Hello, world!").show
ourDialogBox = Wx::MessageDialog.new(ourFrame, "Hello, world!", "Information:", Wx::OK|Wx::ICON_INFORMATION).show_modal
end
end

HelloWorldApp.new.main_loop

84.SWT
===================================
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

public class SWTHello {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
RowLayout layout = new RowLayout();
layout.justify = true;
layout.pack = true;
shell.setLayout(layout);
shell.setText("Hello, World!");
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello, World!");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

85.RTML
===================================
Hello ()
TEXT "Hello, world!"
Qt toolkit (in C++)
#include <qapplication.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <iostream>

class HelloWorld : public QWidget
{
Q_OBJECT

public:
HelloWorld();
virtual ~HelloWorld();
public slots:
void handleButtonClicked();
QPushButton *mPushButton;
};

HelloWorld::HelloWorld() :
QWidget(),
mPushButton(new QPushButton("Hello, World!", this))
{
connect(mPushButton, SIGNAL(clicked()), this, SLOT(handleButtonClicked()));
}

HelloWorld::~HelloWorld() {}

void HelloWorld::handleButtonClicked()
{
std::cout << "Hello, World!" << std::endl;
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
HelloWorld helloWorld;
app.setMainWidget(&helloWorld);
helloWorld.show();
return app.exec();
}

时间: 2024-11-03 18:42:08

各种语言的hello world的相关文章

使用R语言计算均值,方差等

R语言对于数值计算很方便,最近用到了计算方差,标准差的功能,特记录. 数据准备 height <- c(6.00, 5.92, 5.58, 5.92) 1 计算均值 mean(height) [1] 5.855 2 计算中位数 median(height) [1] 5.92 3 计算标准差 sd(height) [1] 0.1871719 4 计算方差 var(height) [1] 0.03503333 5 计算两个变量之间的相关系数 cor(height,log(height)) [1] 0

GCC在C语言中内嵌汇编 asm __volatile__ 【转】

转自:http://blog.csdn.net/pbymw8iwm/article/details/8227839 在内嵌汇编中,可以将C语言表达式指定为汇编指令的操作数,而且不用去管如何将C语言表达式的值读入哪个寄存器,以及如何将计算结果写回C 变量,你只要告诉程序中C语言表达式与汇编指令操作数之间的对应关系即可, GCC会自动插入代码完成必要的操作. 1.简单的内嵌汇编 例: __asm__ __volatile__("hlt"); "__asm__"表示后面的

C语言轻松高效学习方法之:多种方法实现

多种方法实现同一个功能,可以调动你学的所有知识去做,有助于你学的融会贯通. 下面举例来看: 实现功能:求一个整数的位数: 实现语言:C语言: 开发环境:Visual Studio 2017 如:3215是4位数 实现原理: 3215/10 = 321 ----1位数 321/10 = 32 ----又是1位数 32/10 = 3 ----又是1位数 3/10 = 0 ----又是1位数 共4位数,且终止计算条件是/10结果为0的时候: 根据这个原理,先写一个最笨的原始方法: 效果: 这种实现方案

轻松学习C语言编程的秘诀:总结+灵感

目前在准备一套C语言的学习教程,所以我这里就以C语言编程的学习来讲.注意,讲的是"轻松学习",那种不注重方法,拼命玩命的方式也有其效果,但不是我提倡的.我讲究的是在方式方法对头.适合你.减轻你学习负担和心里压力的前提下,才适当的抓紧时间. 因此,探索一种很好的学习方法就是我所研究的主要内容. 众所周知,学习C语言并非易事,要学好它更是难上加难.这和你期末考试背会几个题目的答案考上满分没多大关系,也就是说你考试满分也说明不了你学好.学精通了C语言.那么怎么才算学精通C语言?闭着眼睛对自己

详解go语言的array和slice 【二】

上一篇  详解go语言的array和slice [一]已经讲解过,array和slice的一些基本用法,使用array和slice时需要注意的地方,特别是slice需要注意的地方比较多.上一篇的最后讲解到创建新的slice时使用第三个索引来限制slice的容量,在操作新slice时,如果新slice的容量大于长度时,添加新元素依然后使源的相应元素改变.这一篇里我会讲解到如何避免这些问题,以及迭代.和做为方法参数方面的知识点. slice的长度和容量设置为同一个值 如果在创建新的slice时我们把

自动生成小学四则运算题目(C语言)

这个简易四则运算是我在百度上找的博主叫53余雅诗的一篇c语言代码,网址为http://www.cnblogs.com/ys1101/p/4368103.html,功能是可以选择加减乘除进行简易的四则运算,判断对错.我在VS2017上编译没有bug,因为功能只有整数运算,所以我在此基础上加了真分数的四则运算以及统计得分等,最后成功运行程序.我把我的源代码放在github上,地址为https://github.com/xiaofancheng/helloworld.

PAT 1009 说反话 C语言

给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串.字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保证句子末尾没有多余的空格. 输出格式:每个测试用例的输出占一行,输出倒序后的句子. 输入样例: Hello World Here I Come 输出样例: Come I Here World Hello 1 #include<stdio.h> 2 #

PAT 1006 换个格式输出 C语言

让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它有2个"百".3个"十".以及个位的4. 输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000). 输出格式:每个测试用例的输出占一行,用规定的格式输出n. 输入样例1: 234 输出样例1: BBSSS1

Go语言 IDE之Gogland配置使用

Gogland 是 JetBrains 公司推出的 Go 语言集成开发环境.Gogland 同样基于 IntelliJ 平台开发,支持 JetBrains 的插件体系.目前正式版尚未发布.官方:https://www.jetbrains.com/go/.关于使用,即将开始咯! 一.安装Golang 1) 首先到https://golang.org/dl/选择适合你系统的安装包,(墙内:http://golangtc.com/download). 2)下载完成安装到指定目录即可.我这里是(D:\G

R语言快速上手入门

R语言快速上手入门 课程学习网址:http://www.xuetuwuyou.com/course/196 课程出自学途无忧网:http://www.xuetuwuyou.com 课程简介 本教程深入浅出地讲解如何使用R语言玩转数据.课程中涵盖R语言编程的方方面面,内容涉及R对象的类型.R的记号体系和环境系统.自定义函数.if else语句.for循环.S3类R的包系统以及调试工具等.本课程还通过示例演示如何进行向量化编程,从而对代码进行提速并尽可能地发挥R的潜能.本课程适合立志成为数据科学家的