【小测验】你能看出这是哪种语言写的程序吗?
May 21, 2015
世界上存在的编程语言有上百种,有的非常流行,有的默默无闻。有的适合商用,有的适合教学,有的适合玩耍。初学程序员可能只知道一两种语言,但随着经历越多,学的编程语言种类越多。懂多少种编程语言可以作为一个程序员能力大小的重要标准。如果你想知道自己的实力,请测一下自己,这里一共有12题,看看能选对几种?
Table of Contents
1、
#includeint main() { std::cout << "Hello, World."; }
2、
#!/bin/sh echo "Hello World"
3、
>>> def fib(n): >>> a, b = 0, 1 >>> while a < n: >>> print(a, end=' ') >>> a, b = b, a+b >>> print() >>> fib(1000)
4、
public class Hello {
public static void main(String []args) {
System.out.println("Hello World");
}
}
5、
# The Greeter class
class Greeter
def initialize(name)
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
# Create a new object
g = Greeter.new("world")
# Output "Hello World!"
g.salute
6、
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
7、
$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
8、
#importint main(int argc, char *argv[]) { @autoreleasepool { NSLog(@"Hello World!"); } return 0; }
9、
(defun should-be-constant () '(one two three)) (let ((stuff (should-be-constant))) (setf (third stuff) 'bizarre)) ; bad! (should-be-constant) ; returns (one two bizarre)
10、
class Hello {
static void Main() {
System.Console.Write("Hello World");
}
}
11、
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
12、
Imports System.Console
Module Program
Sub Main()
Dim rows As Integer
Dim current = 1
For row = 1 To rows
For column = 1 To row
Write("{0,-2} ", current)
current += 1
Next
WriteLine()
Next
End Sub
End Module
原文:http://www.vaikan.com/codes-writen-by-programming-languages/
0 Comments