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 ConsoleApplication1
- {
- class Program
- {
- static int[,] sz = new int [5,5];
- static int fsz, i = 0, g;
- static Random r = new Random();
- static void Feltolt()
- {
- for (int x=0; x<5;x++)
- {
- for (int y=0; y<5;y++)
- {
- sz[x,y] = r.Next(10,100);
- }
- }
- }
- static void Rendez()
- {
- for (int Y = 0; Y < 5; Y++)
- {
- for (int x = 0; x < (5 - 1); x++)
- {
- int min = x;
- for (int y = (x + 1); y < 5; y++)
- {
- if (sz[Y,y] < sz[Y,min])
- {
- min = y;
- }
- }
- int tmp = sz[Y,min];
- sz[Y,min] = sz[Y,x];
- sz[Y,x] = tmp;
- }
- }
- }
- static void Kiir()
- {
- for (int c = 0; c < 5; c++)
- {
- for (int v = 0; v < 5; v++)
- {
- Console.Write("{0} ",sz[c, v]);
- }
- Console.WriteLine();
- }
- }
- static void Beker()
- {
- Console.WriteLine("Adjon meg egy számot");
- fsz = int.Parse(Console.ReadLine());
- }
- static void Vizsgal()
- {
- for (int c = 0; c < 5; c++)
- {
- for (int v = 0; v < 5; v++)
- {
- if (sz[c,v] == fsz)
- {
- i++;
- }
- }
- }
- }
- static void Main(string[] args)
- {
- Feltolt();
- Rendez();
- Kiir();
- Beker();
- Vizsgal();
- Console.WriteLine("{0}x található a tömbben", i);
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment