package com.zuoye.test;//打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,//其各位数字立方和等于该数本身.//例如:153是一个 "水仙花数 ",//因为153=1的三次方+5的三次方+3的三次方.public class Shuixian { public static void main(String[] args) { int a; int b; int c; int sum1=0; int su
剑指 Offer 15. 二进制中1的个数 Offer 15 题目描述: 方法一:使用1逐位相与的方式来判断每位是否为1 /** * 方法一:使用1逐位与的方法 */ public class Offer_15 { // you need to treat n as an unsigned value public int hammingWeight(int n) { int sum = 0; while(n != 0){ // 这里不是n > 0作为边界条件 sum += n & 1; n
public class Three_03 { public static void main(String[] args) { for(int i=100;i<1000;i++){ int a=i%10; int b=i/10%10; int c=i/100; if((a*a*a+b*b*b+c*c*c)==i){ System.out.println(i); }else{ continue; } } }}