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 ConsoleApplication11
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random RandNum = new Random();
- int[] array = new int[10];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = RandNum.Next(100);
- Console.WriteLine("Az " + (i + 1) + ". elem: " + array[i]);
- }
- if (tombkeres(array))
- {
- Console.WriteLine("A szám benne van a tömbben.");
- }
- else
- {
- Console.WriteLine("A szám nincs benne a tömbben.");
- }
- }
- static bool tombkeres(int[] tomb)
- {
- Console.Write("Kérem a keresendő számot: ");
- int keres = int.Parse(Console.ReadLine());
- for (int i = 0; i < tomb.Length; i++)
- {
- if (keres == tomb[i])
- {
- return true;
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement