我们学习语言的第一步都是从输出Hello World开始的,下面我们来感受一下不同语言的第一步。
C:
#include <stdio.h>
int main()
{
printf("Hello World !\n");
return 0;
}
C++:
#include <iostream>
#include<string>
using namespace std;
class Displaying
{
private:
string str;
public:
Displaying(string str)
{
this->str = str;
}
void print()
{
cout<<str<<endl;
}
};
int main()
{
Displaying disp("Hello World !");
disp.print();
return 0;
}
Java:
import javax.swing.JOptionPane;
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World !");
JOptionPane.showMessageDialog(null,"Hell world !");
}
}
C#:
using System;
namespace Hello
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
HTML:
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
以上的都是本人在学习过程中接触过的语言,所以列举出来用来做个比较。