20种语言的hello world
在我们学习一个新的编程语言时,往往都要输出hello world,接下来我们看看如何用20种编程语言分别输出hello world
1.java
public class helloworld {
public static void main(String[] args) {
System.out.println("helloworld");
}
}
2.C
#include<stdio.h>
void main()
{
printf("helloworld\n");
return(0);
}
3.C++
#include <iostream>
using namespace std;
void main()
{
cout << "helloworld\n";
}
5.C Sharp(C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace log{
class helloworld{
static void Main(string[] args){
Console.WriteLine("helloworld!");
}
}
}
6.python
print("helloworld")
7.javascript
console.log("helloworld");
8.php
<?php
echo "helloworld!\n" ;
?>
9.asp
<% response.write("helloworld") %>
10.vbscript
msgbox "helloworld"
11.pascal
begin
writeln('helloWorld!');
end.
12.golang
package main
import "fmt"
func main(){
fmt.Printf("helloworld\n");
}
13.prel
print "helloworld";
14.ruby
puts "helloworld"
15.R
cat('helloworld')
16.shell
#!/path
echo "helloworld"
17.html
<h1>helloworld<h1>
18.lua
print("hello world")
20.Objective-C
#import <Foundation/Foundation.h>
int main(int argc,const char *argv[])
{
NSLog(@"Helloworld");
return (0);
}
有疑问加站长微信联系(非本文作者)