hello world程序集锦(2)

AWK

BEGIN { print "Hello, world!" }
Bash (or sh)

echo 'Hello, world!'

或者:

printf 'Hello, world!\n'

BASIC

传统版 BASIC(例如 GWBASIC):

10 PRINT "Hello, world!"
20 END

或在提示符输入:

? "Hello, world!"

现代版 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.


      

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/1615.html