0
点赞
收藏
分享

微信扫一扫

题目:一个四位数,恰好等于去掉它的首位数字之后所剩的三位数的3倍,这个四位数是多少?

扶摇_hyber 2022-02-19 阅读 97
java算法
public class Q5{
	public static void main(String [] args){

		int test1 = -1000;
		for (int i=0;i<=9 ;i++ ){
			test1 +=1000;
			
			int test2 = -100;
			for (int x =0 ; x<=9;x++ ){
			test2 +=100;

				int test3 = -10;
				for (int y =0; y<=9 ; y++ ){
				test3 +=10;

					int test4 = -1;
					for (int z =0; z<=9 ; z++ ){
					test4 +=1;
					

					if ((test2+test3+test4)*3 == (test1+test2+test3+test4) & (test1+test2+test3+test4) != 0){

						System.out.println(test1+test2+test3+test4);
					}
				}
				}

					
			}
		}


	}

}
举报

相关推荐

0 条评论