A+B问题通解_Pascal_C++_Java

  世界不断发展,各种电子设备不断变得更加迷你,代码却越写越长……

  A+B Problem

  Input:Two integer A,B

  Output:The ans of A+B

 

  1971年,Niklaus Wirth 发明 Pascal

  越是早年的语言,内存与运行时间越少,代码也越简单

1 var a,b:longint;
2 begin
3     readln(a,b);
4     writeln(a+b)
5 end.

 

  1983 年 C++ 在 Bjarne Stroustrup 手中诞生

  主要特点是尽量兼容C,且支持面向对象

1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5     int a,b;
6     cin>>a>>b;
7     cout<<a+b;
8     return 0;
9 }

 

  1995 年 Sun Microsystems 通过改进 C++ 发明了 Java

  不难看出 Java 有很多与 C++ 相似的地方

 1 import java.util.Scanner;
 2 public class Main
 3 {
 4     public static void main(String[] args)
 5     {
 6         Scanner in=new Scanner(System.in);
 7         int a=in.nextInt();
 8         int b=in.nextInt();
 9         System.out.println((a+b));
10     }
11 }

 

  重点是代码长度从 5行→9行→11行

  设想 N 年后的代码,会是多少行?

 

  (不过 Python 成功打破了这一规律)

posted @ 2016-10-13 16:13  Hadilo  阅读(471)  评论(0编辑  收藏  举报