您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容主要讲解“怎么用web编程语言实现算法题”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用web编程语言实现算法题”吧!
1、JAVA
import java.lang.reflect.Field; public class Main { public static void main (String[] args) throws Exception { Class cache = Integer.class.getDeclaredClasses ()[0]; Field c = cache.getDeclaredField ("cache"); c.setAccessible (true); Integer[] array = (Integer[]) c.get (cache); array[132] = array[133]; System.out.printf ("%d",2 + 2); } }
输出:
5
2、C
int main () { char __func_version__[] = “5″; // For source control char b[]=”2″, a=2; printf (“%d + %s = %s\n”, a, b, a+b); return 0; }
3、C (Linux, gcc 4.7.3)
#include <stdio.h> int main (void) { int a=3, b=2; printf (“%d + %d = %d”, –a, b, a+b); }
4、Haskell
λ> let 2+2=5 in 2+2 5
5、BBC BASIC
MODE 6 VDU 23,52,254,192,252,6,6,198,124,0 PRINT PRINT “2+2=”;2+2 PRINT “2+3=”;2+3
6、Python
>>> patch = '\x312\x2D7' >>> import ctypes;ctypes.c_int8.from_address (id (len (patch)) +8) .value=eval (patch) >>> 2 + 2 5
7、JavaScript
g = function () { H = 3 return H + H } f = function () { Η = 2 return Η + H } // 3 + 3 = 6 alert (g()) // 2 + 2 = 5 alert (f())
8、Bash
9、PHP
echo ’2 + 2 = ‘ . (2 + 2 === 4 ? 4 : 2 + 2 === 5 ? 5 : ‘dunno’);
10、Perl
# Generic includes use strict; use warnings; use 5.010; use Acme::NewMath; # Ok, time to begin the real program. if (2 + 2 == 5) { say 5; } else { say "Dunno..."; }
11、C#
static void Main (string[] args) { var x = 2; var y = 2; if (1 == 0) ; { ++x; } Console.WriteLine (x + y); }
12、C++
#include <iostream> class Int { public: Int (const int& a) : integ (a) {} friend std::ostream& operator<<(std::ostream& oss, const Int& rhs) { return oss << rhs.integ; } int operator+(Int o) { if(integ == 2 && o.integ == 2) return integ+o.integ+1; return integ+o.integ; } private: int integ; }; int main () { Int two = 2; std::cout << two << " + " << two << " = " << two + two; }
到此,相信大家对“怎么用web编程语言实现算法题”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。