Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package finder;
- import java.util.Scanner;
- /**
- *
- * @author Quentin
- */
- public class Finder {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- System.out.println("pensez à un nombre entre 1 et 100");
- Scanner sc = new Scanner(System.in);
- int bornesup = 100;
- int borneinf = 0;
- System.out.println("Est-ce " + Integer.toString((bornesup + borneinf)/2) + "?");
- int rep = sc.nextInt();
- while (rep != 0){
- if (rep == 1){
- borneinf = (bornesup + borneinf)/2;
- }
- else{
- bornesup = (bornesup + borneinf)/2;
- }
- System.out.println("Est-ce " + Integer.toString((bornesup + borneinf)/2) + "?");
- rep = sc.nextInt();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement