Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace listásegyebes
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Random rand = new Random();
- List<int> lista = new List<int>(); // ez egy int lista, amit használhatok tömbként
- feltöltés(rand, lista);
- int t = bekérés();
- ifcontains(lista, t);
- Console.ReadLine();
- }
- }
- private static int bekérés()
- {
- Console.WriteLine("Milyen számot keresel?");
- int t = int.Parse(Console.ReadLine());
- return t;
- }
- private static void ifcontains(List<int> lista, int t)
- {
- if (lista.Contains(t))
- {
- Console.WriteLine("Van benne {0}!", t);
- }
- else
- {
- Console.WriteLine("Nincs benne {0}!", t);
- }
- }
- private static void feltöltés(Random rand, List<int> lista)
- {
- for (int i = 0; i < 20; i++)
- {
- lista.Add(rand.Next(15));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement