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 ConsoleApplication1
- {
- class Program
- {
- static void tombfeltolt(int [,] tomb, Random vel, int sorsz, int oszlopsz)
- {
- for (int j = 0; j < sorsz; j++ )
- {
- for (int i = 0; i < oszlopsz; i++)
- {
- tomb[j, i] = vel.Next(10, 100);
- }
- }
- }
- static int pluszok = 0;
- static int minuszok = 0;
- static void tombfeltolt2(int [,] tomb, char [,] tomb2, int sorsz, int oszlopsz)
- {
- for (int j = 0; j < sorsz; j++)
- {
- for (int i = 0; i < oszlopsz; i++)
- {
- if (tomb[j, i] > 50)
- {
- tomb2[j, i] = '+';
- pluszok++;
- }
- else
- {
- tomb2[j, i] = '-';
- minuszok++;
- }
- }
- }
- }
- static void kiir(int [,] tomb, int sorsz, int oszlopsz)
- {
- for (int j = 0; j < sorsz; j++)
- {
- for (int i = 0; i < oszlopsz; i++)
- {
- Console.Write("{0} ", tomb[j, i]);
- }
- Console.WriteLine();
- }
- }
- static void kiir2(char[,] tomb, int sorsz, int oszlopsz)
- {
- for (int j = 0; j < sorsz; j++)
- {
- for (int i = 0; i < oszlopsz; i++)
- {
- Console.Write("{0,2} ", tomb[j, i]);
- }
- Console.WriteLine();
- }
- }
- static void Main(string[] args)
- {
- Random vel = new Random();
- int sorsz = 5, oszlopsz = 5;
- int [,] tomb = new int[sorsz,oszlopsz];
- char [,] tomb2 = new char[sorsz, oszlopsz];
- tombfeltolt(tomb, vel, sorsz, oszlopsz);
- kiir(tomb, sorsz, oszlopsz);
- Console.WriteLine();
- tombfeltolt2(tomb, tomb2, sorsz, oszlopsz);
- kiir2(tomb2, sorsz, oszlopsz);
- Console.WriteLine("A pluszok száma: {0}, A mínuszok száma: {1}", pluszok, minuszok);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement