HelloWorld 大全

代码高亮居然成功了!感谢 Kate 编辑器!

1. 汇编(NASM,Intel 语法,仅 Linux x86)

section .data
    msg: db "Hello, world!", 0Ah
    .length: equ $ - msg

section .text
    global _start

_start:
    mov eax, 4h
    mov ebx, 1h
    mov ecx, msg
    mov edx, msg.length
    int 80h
    mov eax, 1h
    mov ebx, 0h
    int 80h

2. 汇编(GAS,AT&T 语法,仅 Linux x86)

.data
	msg: .ascii "Hello, world!\n"
	msg.length = . - msg

.text
	.global _start

_start:
	movl $4, %eax
	movl $1, %ebx
	movl $msg, %ecx
	movl $msg.length, %edx
	int $0x80
	movl $1, %eax
	movl $0, %ebx
	int $0x80

3. C

#include <stdio.h>

int main(void)
{
	puts("Hello, world!");
	return 0;
}

4. C++

#include <iostream>

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

5. Java

public class Hello
{
	public static void main(String[] args)
	{
		System.out.println("Hello, world!");
	}
}

6. C#

public class Hello
{
	public static void Main(string[] args)
	{
		System.Console.WriteLine("Hello, world!");
	}
}

7. D

import std.stdio;

int main(string[] args)
{
	writefln("Hello, world!");
	return 0;
}

8. Objective-C

#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
	NSLog(@"Hello, world!");
	return 0;
}

9. Pascal

Program Hello;

Begin
	WriteLn('Hello, world!');
End.

10. Bash

echo "Hello, world!"

11. DOS Batch

@echo off
echo Hello, world!

12. Qt/C++

#include <QApplication>
#include <QLabel>

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

大笑

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值