open Printf open Scanf let find ar h w = let rec iter i j ps = if i = h then ps else if j = w then iter (i+1) 0 ps else if ar.(i).[j] = '*' then iter i (j+1) ((i,j) :: ps) else iter i (j+1) ps in iter 0 0 [] let print_tbl ar w x y = Array.iteri (fun i s -> if i = x then printf "%s\n" (String.init w (fun j -> if j = y then '*' else s.[j])) else printf "%s\n" s) ar let () = let h, w = scanf "%d %d " (fun x y -> (x, y)) in let tbl = Array.init h (fun _ -> let s = scanf "%s " (fun x -> x) in s) in match find tbl h w with (x1, y1) :: (x2, y2) :: _ -> begin let rec loop i j = if j = w then loop (i+1) 0 else if (x1-i) * (y2-j) - (y1-j) * (x2-i) = 0 then loop i (j+1) else print_tbl tbl w i j in loop 0 0 end | _ -> failwith "find"