热门

最新

红包

立Flag

投票

同城

我的

发布
jjtiamojr
MuZi_Lee-
5 年前
truejjtiamojr

package com.limuzi01;

import java.util.Scanner;

public class 水仙花 {
public static void main(String[] args){
for(int x=100;x<1000;x++){
int a = x%10;
int b = x/100;
int c = x/10%10;
if(a*a*a+b*b*b+c*c*c==x){
System.out.println(x);
}
}

}
}

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
package com.limuzi01;import java.util.Scanner;public class 查找 { public static void main(String[] args){ int[] arr={10,20,30,40,50,60,70,80}; Scanner sr = new Scanner(System.in); System.out.println("请输入要查找的数:"); int number = sr.nextInt(); int Index = GetIndex(arr,number); System.out.println("Index:"+Index); } public static int GetIndex(int[] arr,int number){ int Index = -1; for(int x=0;x<arr.length;x++){ if(number==arr[x]){ Index=x; break; } } return Index; }}
立即登录