Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #use "AP1utilbis.ml" ;;
- #use "AP1saisie5.ml" ;;
- let get_intver(v_min, v_max : int * int) : int =
- let v : int ref = ref 0 and thend : bool ref = ref false in
- (
- while not(!thend)
- do
- print_string("saisissez votre annee de naissance") ;
- v := read_int() ;
- if !v < 2003
- then (print_string("Vous etes trop jeune! Revenez l'an prochaine") ; print_newline() ;)
- else
- if !v > 2005
- then (print_string("Vous etes trop trop vieux! Rien a faire la..") ; print_newline() ;);
- thend := ( !v >= v_min && !v <= v_max);
- done;
- !v;
- )
- ;;
- let get_id() : int =
- let v : int ref = ref 0 and thend : bool ref = ref false in
- (
- while not( !thend)
- do
- print_string("saisissez votre numero de licence: ") ;
- v := read_int() ;
- thend := ( !v >= 0) ;
- done ;
- !v ;
- )
- ;;
- let get_poids() : int =
- let v : int ref = ref 0 and thend : bool ref = ref false in
- (
- while not( !thend)
- do
- print_string("saisissez votre poids: ") ;
- v := read_int() ;
- thend := ( !v >= 0) ;
- done ;
- !v ;
- )
- ;;
- type t_judoka = {nom : string ; yob : int ; id : int ; poids : int;};;
- (* yob = year of birth, id = identification*)
- let cat_weight_tab = [|46 ; 50 ; 55 ; 60 ; 66 ; 73 ; 81 ; 90 ; 90|];;
- let cat_playerNum_tab = [|0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0|];;
- let get_judoka() : t_judoka =
- {nom = "placeholder" ; yob = get_intver(2003, 2005); id = get_id() ; poids = get_poids()}
- ;;
- let cat_num = 9;;
- let registration_tab() : (int*int) array =
- let v : (int*int) array = arr_make(9, (0,0)) in
- (
- for i = 1 to 9
- do
- v.(i-1) <- (cat_weight_tab.(i-1), cat_playerNum_tab.(i-1));
- done ;
- v;
- )
- ;;
- let registration(b : int) : int * int array =
- let m : t_judoka ref = ref {nom = "0" ; yob = 0; id = 0 ; poids = b} in
- let pos : int ref = ref 1 in
- (*m := get_judoka();*)
- (
- for i = 1 to 8
- do
- if !m.poids < cat_weight_tab.(i-1)
- then
- pos := !pos
- else
- if !m.poids > cat_weight_tab.(i-1)
- then pos := !pos + 1
- else
- if !m.poids > 90
- then pos := 8;
- done ;
- cat_playerNum_tab.(!pos) <- cat_playerNum_tab.(!pos) + 1;
- !pos-1,cat_playerNum_tab;
- )
- ;;
- let testtab(n : int) : int array =
- for i = 1 to n-1
- do
- registration((rand_int(30, 100)));
- done;
- cat_playerNum_tab;
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement