用所有语言写“Hello, World!“

C语言:

#include <stdio.h>

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

C++语言:

#include <iostream>

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

Java语言:

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

Python语言:

print("Hello, World!")

C#语言:

using System;

class Program {
    static void Main() {
        Console.WriteLine("Hello, World!");
    }
}

JavaScript语言:

console.log("Hello, World!");

Ruby语言:

puts "Hello, World!"

PHP语言:

<?php
echo "Hello, World!";
?>

Swift语言:

print("Hello, World!")

Kotlin语言:

fun main() {
    println("Hello, World!")
}

Go语言:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Rust语言:

fn main() {
    println!("Hello, World!");
}

HTML/CSS(网页显示 “Hello, World!”):

<!DOCTYPE html>
<html>
<head>
    <title>Hello, World!</title>
    <style>
        body {
            text-align: center;
            font-size: 24px;
            margin-top: 20%;
        }
    </style>
</head>
<body>
    <p>Hello, World!</p>
</body>
</html>

F#语言:

open System

[<EntryPoint>]
let main argv =
    Console.WriteLine("Hello, World!")
    0 // return an integer exit code

Haskell语言:

main = putStrLn "Hello, World!"

Lisp语言:

(format t "Hello, World!")

Erlang语言:

-module(hello).
-export([hello_world/0]).

hello_world() ->
    io:format("Hello, World!~n").

Prolog语言:

hello_world :- write('Hello, World!'), nl.

Datalog语言(类似Prolog):

hello_world :- writeln('Hello, World!').

Smalltalk语言:

Transcript show: 'Hello, World!'; cr.

Object Pascal语言:

program HelloWorld;
begin
    writeln('Hello, World!');
end.

Objective-C语言:

#import <Foundation/Foundation.h>

int main() {
    @autoreleasepool {
        NSLog(@"Hello, World!");
    }
    return 0;
}

Swift语言(iOS):

import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        print("Hello, World!")
    }
}

Kotlin语言(Android):

fun main() {
    println("Hello, World!")
}

Java语言(Android):

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        System.out.println("Hello, World!");
    }
}

React Native框架(JavaScript):

import React from 'react';
import { Text, View } from 'react-native';

const App = () => {
  return (
    <View>
      <Text>Hello, World!</Text>
    </View>
  );
};

export default App;

Flutter框架(Dart):

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Center(
      child: Text('Hello, World!'),
    ),
  ));
}

Lua语言:

print("Hello, World!")

Assembly语言:

section .data
    hello db 'Hello, World!', 0

section .text
    global _start

_start:
    mov eax, 4
    mov ebx, 1
    mov ecx, hello
    mov edx, 13
    int 0x80

    mov eax, 1
    xor ebx, ebx
    int 0x80

Ada语言:

with Ada.Text_IO;

procedure Hello is
begin
    Ada.Text_IO.Put_Line("Hello, World!");
end Hello;

SQL语言:

SELECT 'Hello, World!';

R语言:

print("Hello, World!")

XML

<text>
    Hello, World!
</text>

  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

正在闭关修炼中

作者才10岁鼓励一下吧!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值