Ввести одномерный массив размерностью n. Вывести значение и номер последнего четного элемента или сообщение об отсутствии четных значений.
Ответы
Ответ дал:
0
// F#
[<EntryPoint>]
let main argv =
let elements =
System.Console.ReadLine().Split(' ')
|> Seq.map (fun x -> System.Int32.Parse x)
|> Seq.mapi (fun i x -> (x, i))
|> Seq.where (fun (x, i) -> x % 2 = 0)
if elements |> Seq.length > 0
then System.Console.WriteLine("{0} {1}", elements |> Seq.last |> fst, (elements |> Seq.last |> snd) + 1)
else System.Console.WriteLine("No results")
System.Console.ReadKey true |> ignore
0
[<EntryPoint>]
let main argv =
let elements =
System.Console.ReadLine().Split(' ')
|> Seq.map (fun x -> System.Int32.Parse x)
|> Seq.mapi (fun i x -> (x, i))
|> Seq.where (fun (x, i) -> x % 2 = 0)
if elements |> Seq.length > 0
then System.Console.WriteLine("{0} {1}", elements |> Seq.last |> fst, (elements |> Seq.last |> snd) + 1)
else System.Console.WriteLine("No results")
System.Console.ReadKey true |> ignore
0
Вас заинтересует
1 год назад
1 год назад
1 год назад
1 год назад
7 лет назад