Guest User

Untitled

a guest
May 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static int[,] sz = new int [5,5];
  11.         static int fsz, i = 0, g;
  12.         static Random r = new Random();
  13.         static void Feltolt()
  14.         {
  15.             for (int x=0; x<5;x++)
  16.             {
  17.                 for (int y=0; y<5;y++)
  18.                 {
  19.                     sz[x,y] = r.Next(10,100);
  20.                 }
  21.             }
  22.         }
  23.         static void Rendez()
  24.         {
  25.             for (int Y = 0; Y < 5; Y++)
  26.             {
  27.                 for (int x = 0; x < (5 - 1); x++)
  28.                 {
  29.                     int min = x;
  30.                     for (int y = (x + 1); y < 5; y++)
  31.                     {
  32.                         if (sz[Y,y] < sz[Y,min])
  33.                         {
  34.                             min = y;
  35.                         }
  36.  
  37.                     }
  38.                     int tmp = sz[Y,min];
  39.                     sz[Y,min] = sz[Y,x];
  40.                     sz[Y,x] = tmp;
  41.  
  42.                 }
  43.             }
  44.         }
  45.         static void Kiir()
  46.         {
  47.             for (int c = 0; c < 5; c++)
  48.             {
  49.                 for (int v = 0; v < 5; v++)
  50.                 {
  51.                     Console.Write("{0} ",sz[c, v]);
  52.                 }
  53.                 Console.WriteLine();
  54.             }
  55.         }
  56.         static void Beker()
  57.         {
  58.             Console.WriteLine("Adjon meg egy számot");
  59.             fsz = int.Parse(Console.ReadLine());
  60.         }
  61.         static void Vizsgal()
  62.         {
  63.            
  64.             for (int c = 0; c < 5; c++)
  65.             {
  66.                 for (int v = 0; v < 5; v++)
  67.                 {
  68.                    
  69.                     if (sz[c,v] == fsz)
  70.                     {
  71.                         i++;
  72.                     }    
  73.                 }
  74.                
  75.             }
  76.         }
  77.         static void Main(string[] args)
  78.         {
  79.             Feltolt();
  80.             Rendez();
  81.             Kiir();
  82.             Beker();
  83.             Vizsgal();
  84.             Console.WriteLine("{0}x található a tömbben", i);
  85.             Console.ReadKey();
  86.         }
  87.     }
  88. }
Add Comment
Please, Sign In to add comment