日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
有趣啊!各種編程語言實現(xiàn)2+2=5

今天在 stackexchange 上看到一篇非常有趣的帖子,是關(guān)于如何用各種編程語言實現(xiàn) 2 + 2 = 5 的,2 + 2 怎么會等于 5 呢?我一開始也很不解,不過看了下面各種編程語言實現(xiàn)的方法,我震驚了,讓我又一次相信人類真是一種不可思議的生物。

我們提供的服務(wù)有:成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、靈丘ssl等。為上1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的靈丘網(wǎng)站制作公司

1、JAVA

  
 
  1. import java.lang.reflect.Field;
  2. public class Main {
  3.     public static void main (String[] args) throws Exception {
  4.         Class cache = Integer.class.getDeclaredClasses ()[0];
  5.         Field c = cache.getDeclaredField ("cache");
  6.         c.setAccessible (true);
  7.         Integer[] array = (Integer[]) c.get (cache);
  8.         array[132] = array[133];
  9.         System.out.printf ("%d",2 + 2);
  10.     }
  11. }

輸出:

5

2、C

  
 
  1. int main () {
  2.     char __func_version__[] = “5″; // For source control char b[]=”2″, a=2;
  3.     printf (“%d + %s = %s\n”, a, b, a+b);
  4.     return 0;
  5. }

3、C (Linux, gcc 4.7.3)

  
 
  1. #include 
  2. int main (void)
  3. {
  4.     int a=3, b=2;
  5.     printf (“%d + %d = %d”, –a, b, a+b);
  6. }

4、Haskell

  
 
  1. λ> let 2+2=5 in 2+2 5

5、BBC BASIC

  
 
  1. MODE 6
  2. VDU 23,52,254,192,252,6,6,198,124,0
  3. PRINT
  4. PRINT “2+2=”;2+2
  5. PRINT “2+3=”;2+3

6、Python

  
 
  1. >>> patch = '\x312\x2D7' >>> import ctypes;ctypes.c_int8.from_address (id (len (patch)) +8) .value=eval (patch)
  2. >>> 2 + 2 5

7、JavaScript

  
 
  1. g = function () {
  2.   H = 3 return H + H
  3. }
  4. f = function () {
  5.   Η = 2 return Η + H
  6. }
  7. // 3 + 3 = 6 alert (g())
  8. // 2 + 2 = 5 alert (f())

8、Bash

9、PHP

  
 
  1. echo ’2 + 2 = ‘ . (2 + 2 === 4 ? 4 : 2 + 2 === 5 ? 5 : ‘dunno’);

10、Perl

  
 
  1. # Generic includes use strict;
  2. use warnings;
  3. use 5.010;
  4. use Acme::NewMath;
  5. # Ok, time to begin the real program. if (2 + 2 == 5) {
  6.     say 5;
  7. }
  8. else {
  9.     say "Dunno...";
  10. }

11、C#

  
 
  1. static void Main (string[] args)
  2. {
  3.     var x = 2;
  4.     var y = 2;
  5.     if (1 == 0) ;
  6.     {
  7.         ++x;
  8.     }
  9.     Console.WriteLine (x + y);
  10. }

12、C++

  
 
  1. #include 
  2. class Int
  3. {
  4. public:
  5.     Int (const int& a) : integ (a) {}
  6.     friend std::ostream& operator<<(std::ostream& oss, const Int& rhs)
  7.     {
  8.         return oss << rhs.integ;
  9.     }
  10.     int operator+(Int o)
  11.     {
  12.         if(integ == 2 && o.integ == 2)
  13.             return integ+o.integ+1;
  14.         return integ+o.integ;
  15.     }
  16. private:
  17.     int integ;
  18. };
  19. int main ()
  20. {
  21.     Int two = 2;
  22.     std::cout << two << " + " << two << " = " << two + two;
  23. }

各位有什么補充的,發(fā)揮你的想象吧,評論中告訴我們。


文章標(biāo)題:有趣??!各種編程語言實現(xiàn)2+2=5
瀏覽地址:http://www.dlmjj.cn/article/cdjosdc.html