package homework;
import util.StringUtil;
/**
* 八位数: 2 _ _ _ _ _ _ 5
* 每相邻三个数字和为11
*
* @author ZengWenFeng
* @email 117791303@qq.com
* @mobile 13805029595
* @date 2023.09.17
*/
public class Math_2023_09_17
{
public static boolean isOk(String str, int sum)
{
int s = 0;
// System.out.println(str.substring(0, 1));
// System.out.println(str.substring(1, 2));
// System.out.println(str.substring(2, 3));
s += Integer.parseInt(str.substring(0, 1));
s += Integer.parseInt(str.substring(1, 2));
s += Integer.parseInt(str.substring(2, 3));
return s == sum;
}
public static void test()
{
String curNum;
String temp;
for (int i = 0; i < 1000000; i++)
{
// System.out.println();
curNum = Integer.toString(i);
curNum = "2" + StringUtil.getZeroStr(6 - curNum.length()) + curNum + "5";
temp = curNum.substring(0, 3);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
temp = curNum.substring(1, 4);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
temp = curNum.substring(2, 5);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
temp = curNum.substring(3, 6);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
temp = curNum.substring(4, 7);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
temp = curNum.substring(5, 8);
// System.out.print(" " + temp);
if (!isOk(temp, 11))
{
// System.out.println();
continue;
}
System.out.println(curNum);//25425425
}
}
public static void main(String[] args)
{
// boolean b = isOk("254", 11);
// System.out.println(b);
// String curNum = "12345678";
// String temp = curNum.substring(0, 3);
// System.out.print(" " + temp);
// temp = curNum.substring(1, 4);
// System.out.print(" " + temp);
// temp = curNum.substring(2, 5);
// System.out.print(" " + temp);
// temp = curNum.substring(3, 6);
// System.out.print(" " + temp);
// temp = curNum.substring(4, 7);
// System.out.print(" " + temp);
// temp = curNum.substring(5, 8);
// System.out.print(" " + temp);
test();
}
}