分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
- /**
- * Java得到一个整数的绝对值,不使用任何判断和比较语句,包括API. <br>
- * 1、不得使用任何API,如Math.abs()等。<br>
- * 2、不得使用判断语句,如if、for、while、switch、?:等。<br>
- * 3、不得使用比较语句,如:==、 <=、>=、!=、 <、>等。 <br>
- *
- * @author JAVA世纪网(java2000.net, laozizhu.com)
- */
- public class Test {
- public static void main(String[] args) {
- for (int i = -5; i <= 5; i++) {
- System.out.println(abs(i));
- }
- }
- public static int abs(int num) {
- return num * (1 - ((num >>> 31)<<1));
- }
- }
题目来自于论坛:
http://topic.csdn.net/u/20090906/00/ac08330f-0da6-4299-bf12-8545360d06ab.html
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)