- 问答
- 2019-04-11 11:42:57 @
import java.util.Scanner;
import java.io.PrintStream;
public class Main3 {
public static void main(String[] args)
throws java.io.UnsupportedEncodingException {
PrintStream ps = new PrintStream(System.out, true, "UTF-8");
Scanner in = new Scanner(System.in);
// 请从下一行开始你的程序
int shishu = in.nextInt();
int caishu = 0;
int zhuida = 1000;
int zhuidi = 1;
int cishu = 0;
int cs = 10;
while (caishu != shishu) {
if (caishu > shishu) {
zhuida = caishu;
caishu = (zhuida + zhuidi) / 2;
cs=cs-1;
cishu=cishu+1;
ps.println("第"+cishu+"次:"+caishu);
}
if (caishu < shishu) {
zhuidi = caishu;
caishu = (zhuida + zhuidi) / 2;
cishu=cishu+1;
cs=cs-1;
ps.println("第"+cishu+"次:"+caishu);
}
if(cs==0)
{
break;
}
}
}
}
1 条评论
-
小熊 (wlnirvana) LV 8 MOD @ 2019-04-11 20:31:17
因为你的代码有bug
- 1