Ruby
xxxxxxxxxx
require 'set'
Vegetable=Set.new(["potato","brocolli","broccoflower","lentils","peas","fennel","chilli","cabbage"])
puts "Enter the element:-"
element = gets.chomp
val = Vegetable === element
if val == true
puts "#{element} is Present in the set."
else
puts "#{element} is not Present in the set."
end
Enter the element:- tomato tomato is not Present in the set.
пример 2
Ruby
xxxxxxxxxx
require 'set'
Vegetable=Set.new(["potato","brocolli","broccoflower","lentils","peas","fennel","chilli","cabbage"])
puts "Enter the element:-"
element = gets.chomp
val1 = false
Vegetable.each do |string|
if string == element
val1 = true
end
end
if val1 == true
puts "#{element} is present in the set."
else
puts "#{element} is not present in the set."
end
Enter the element:- tomato tomato is not Present in the set.
Linux - Как установить anc-api-tools
Linux - Как установить curvedns
Linux - Как установить zenmap
Python - Проверьте, является ли число положительным, отрицательным или 0
C - Подсчитать количество цифр в целом числе
C++ - Проверить, является ли число простым или нет
C - Найдите наибольшее число, используя динамическое выделение памяти
C++ - Проверить високосный год
Kotlin - Перевернуть число
JavaScript - Проверьте, начинается ли строка и заканчивается ли она определенными символами
Linux - Как установить zstd
C++ - Найти частное и остаток
Linux - Как установить xbitmaps
Kotlin - Округлить число до n знаков после запятой
Python - Запись файлов Excel (XLSX)
Java - Перевернуть число
Kotlin - Найти факториал числа
Java - Создайте пирамиду и узор
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month