62,617
社区成员
发帖
与我相关
我的任务
分享
public class AbsCal {
public static void main(String[] args) {
for(int i=-10; i<10; i++)
System.out.println("abs("+i+") = "+abs(i));
}
public static int abs(int num) {
return ~num +1;
}
}
public static int myabs(int num){
return (num < 0) ? -num : num;
}
int test=-9;
String str=String.valueOf(test);
str=str.startsWith("-")?str.split("-")[1]:str;
test=Integer.parseInt(str);
System.out.println(test);