成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

有趣啊!各種編程語言實現(xiàn) 2 + 2 = 5

開發(fā) 后端 開發(fā)工具
今天在 stackexchange 上看到一篇非常有趣的帖子,是關(guān)于如何用各種編程語言實現(xiàn) 2 + 2 = 5 的,2 + 2 怎么會等于 5 呢?我一開始也很不解,不過看了下面各種編程語言實現(xiàn)的方法,我震驚了。

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

1、JAVA

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

輸出:

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;  

 

3、C (Linux, gcc 4.7.3)

 

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

 

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.  
  5. f = function () {  
  6.   Η = 2 return Η + H  
  7. }  
  8.  
  9. // 3 + 3 = 6 alert (g())  
  10. // 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.  
  6. # Ok, time to begin the real program. if (2 + 2 == 5) {  
  7.     say 5;  
  8. }  
  9. else {  
  10.     say "Dunno...";  

 

11、C#

 

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

 

12、C++

 

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

 

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

原文鏈接:http://news.html5tricks.com/2-2-5-with-all-language.html

本文作者:html5tricks – 蔣麗麗

責任編輯:林師授 來源: html5tricks
相關(guān)推薦

2014-03-31 15:26:45

Git代碼托管

2021-04-12 18:44:47

編程語言合子

2020-07-24 09:40:04

C語言OOP代碼

2015-07-20 11:32:07

編程語言

2021-02-19 11:55:36

C語言MD5加密

2011-08-05 17:54:33

Cocoa Touch 多語言

2022-11-01 18:29:25

Go語言排序算法

2020-08-12 08:56:30

代碼凱撒密碼函數(shù)

2013-02-21 17:02:00

C語言

2023-05-08 07:55:05

快速排序Go 語言

2024-08-29 13:23:04

WindowsGo語言

2020-02-14 09:19:12

編程語言JavaPython

2011-04-08 11:15:20

編程語言編程游戲開發(fā)

2013-02-25 09:31:35

Web編程語言

2011-05-30 15:00:06

編程語言

2009-02-18 09:11:22

編程語言排行榜Tiobe

2012-02-07 08:48:00

編程語言排行榜

2010-03-29 17:56:20

Nginx反向代理

2012-03-13 10:40:58

Google Go

2022-05-19 14:14:26

go語言限流算法
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 一二三在线视频 | 91九色婷婷 | 天天操天天摸天天爽 | 一区二区三区四区国产 | 久久久高清 | 看片91 | 无码一区二区三区视频 | 日韩视频一区二区三区 | 国产精品无码专区在线观看 | 一区二区在线不卡 | 中文字幕国产一区 | 亚洲一二三区免费 | 免费一级欧美在线观看视频 | 午夜精品久久久久久不卡欧美一级 | 黄色在线免费观看 | 国产一区91精品张津瑜 | www.一区二区三区.com | 久久91精品 | 国产精品久久久久久久久久久新郎 | 亚洲精品福利在线 | 亚洲精品乱码久久久久久蜜桃 | 亚洲欧洲日本国产 | 成人在线免费 | 国产一级大片 | av男人的天堂在线 | 亚洲国产二区 | 成人性生交大免费 | 日韩不卡一区二区三区 | 天天爽天天干 | 成人免费网站视频 | 视频1区 | 亚洲色图婷婷 | 日韩精品成人 | 亚洲精品欧美 | 亚洲成人动漫在线观看 | 一区二区三区日韩 | 亚洲视频国产视频 | 国产精品一区二区在线 | 91中文视频| 91精品国产一区二区三区 | 亚洲精品欧洲 |