Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- let rec isElem list x =
- if (List.isEmpty(list) <> true) then
- if List.head(list) = x then true
- else isElem (List.tail(list)) x
- else false
- let rec new_list list1 list2 list3 =
- if (List.isEmpty(list1) <> true) then
- if (isElem list2 (List.head(list1)) = false) && (isElem list3 (List.head(list1)) = false)
- then
- let l = List.head(list1) :: list3
- new_list (List.tail(list1)) list2 l
- else new_list (List.tail(list1)) list2 list3
- else list3
- let rec count list x k =
- if (List.isEmpty(list) <> true) then
- if x = List.head(list) then
- count (List.tail(list)) x (k+1)
- else count (List.tail(list)) x k
- else k
- printf "Задача 2. Не повторяющиеся элементы в списках\n Количество элементов в списке 1: "
- let n1 = Convert.ToInt32(Console.ReadLine())
- printfn " Элементы списка 1: "
- let list1 = [for i in 1..n1 -> Convert.ToInt32(Console.ReadLine())]
- printf " Количество элементов в списке 2: "
- let n2 = Convert.ToInt32(Console.ReadLine())
- printfn " Элементы списка 2: "
- let list2 = [for i in 1..n2 -> Convert.ToInt32(Console.ReadLine())]
- printfn " Список 1: %A" list1
- printfn " Список 2: %A" list2
- let temp = []
- let list3 = new_list list1 list2 temp
- let list4 = new_list list2 list1 temp
- let list_union = list3 @ list4
- let result_list = List.sort(list_union)
- printfn " Список 3: %A" result_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement