- import java.math.*;
- public class Age {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String rel;
- for (int i = 18; i <= 21; i++) {
- rel = String.valueOf((int) Math.pow(i, 3))
- + String.valueOf((int) (Math.pow(i, 4))); //把两个数组合成字符串
- int is = 0;
- int sum = 0;
- for (int j = 48; j <= 57; j++) { //循环查找字符串中是否包含0-9,找到一个后sum+1
- is = rel.indexOf(j);
- if (is == -1)
- break;
- sum = sum + 1;
- }
- if (sum == 10) { //如果找到10次,输出结果
- System.out.println("此人年龄是:" + i);
- break;
- }
- }
- }
- }
复制代码 完成
|