世界上的第一个程序 ———— Hello World
C
1 2 3 4 5 6
| #include <stdio.h> int main() #main 入口函数 { printf("Hello World!"); #printf 函数打印 return 1; #函数返回值 }
|
C++
1 2 3 4 5 6 7 8 9 10 11
| #include <iostream> //std::cout 要用到的头文件 #include <stdio.h> //标准输入输出头文件 int main() { printf("Hello World!--Way 1\n"); puts("Hello World!--Way 2"); puts("Hello " " " "World!--Way 3"); std::cout << "Hello World!--Way 4" << std::endl; return 1; }
|
C
1 2 3 4 5 6 7 8 9
| using System; class TestApp { public static void Main() { Console.WriteLine("Hello World!"); Console.ReadKey(); } }
|
VB
1 2 3 4 5
| Module Hello Sub Main() MsgBox("Hello World!") End Sub End Module
|
Java
1 2 3 4 5 6 7 8 9
| public class HelloWorld #如果有 public 类的话,类名必须和文件同名,注意大小写 { #Java 入口程序,程序从此入口 public static void main(String[] args) { #向控制台打印一条语句 System.out.println("Hello World!"); } }
|
Python
1 2 3 4
| >>>> print "Hello World!" Hello,World! >>> print("Hello World!") Hello,World!
|
PHP
1 2 3 4 5 6 7 8 9
| <!DOCTYPE html> <body> <?php echo "Hello World!"; echo "The first php program!"; echo phpinfo(); ?> </body> </html>
|
HTML
1 2 3 4 5 6
| <!DOCTYPE html> <html> <body> <h1>Hello World!</h1> </body> </html>
|
CSS
1 2 3 4
| *:before, *:after { content:'Hello World' }
|
JavaScript
1 2 3 4 5
| <script> document.write('Hello World'); console.log('Hello World'); </script>
|