7-1 Hello World! (5分)
本题要求编写程序,输出一个短句“Hello World!”。
输入格式:本题目没有输入。
输出格式:在一行中输出短句“Hello World!”。
java
public class Main{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
C语言
#include<stdio.h>
int main()
{
printf("Hello World!");
}
python
print("Hello World!")
Bash
#!/bin/sh
echo "Hello, World!"
C++
#include <iostream>
int main
{
std::cout << "Hello, world!n";
}
C#
using System;
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, world!");
}
}
COBOL
Identification Division.
Program-ID. sampleCOBOL.
Data Division.
Procedure Division.
Main-Paragraph.
Display "Hello World!"
Stop Run.
Go
package main
import fmt "fmt"
func main
{
fmt.Printf("Hello, World!n");
}
Haskell
module Main (main) where
main = putStrLn "Hello, World!"
Objective-C:
#import <Cocoa/Cocoa.h>
@interface hello : NSObject {
}
@end
@implementation hello
-(void)awakeFromNib
{
NSRunAlertPanel(@"Message from your Computer", @"Hello, World!", @"Hi!",
nil, nil);
}
@end
Pascal
program hello;
begin
writeln('Hello, World!');
end.
Perl 6
say "Hello world!";
PHP:
<?php
echo 'Hello, World!';
?>
Ruby
puts "Hello, World!"
Scala:
object HelloWorld with Application {
Console.println("Hello, World!");
}
SQL
CREATE TABLE message (text char(15));
INSERT INTO message (text) VALUES ('Hello, World!');
SELECT text FROM message;
DROP TABLE message;
Swift
println("Hello World!")
Visual Basic .NET:
Imports System
Public Module modmain
Sub Main
Console.WriteLine ("Hello World using Visual Basic!")
End Sub
End Module
Lisp
(format t "Hello, World!~%")
Kotlin:
package demo
fun main(args : Array) {
println("Hello, world!")
}
R
cat("Hello worldn")
Matlab:
disp('Hello world')
或
fprintf('Hello, world!')
Delphi:
program Hello_World;
uses
Windows;
begin
ShowMessage("Hello, World!");
end