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;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Manager();
- }
- public static void Manager()
- {
- int[,] p = Create2D(60, 60);
- Display2D(p);
- var lista = StringLine(p);
- File.WriteAllLines(@"C:\Users\pclab\Desktop\numera.txt",lista);
- }
- public static int[,] Create2D (int x, int y)
- {
- Random tixaios = new Random();
- int[,] p = new int[x, y];
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- p[i, j] = tixaios.Next(0, 10);
- }
- }
- return p;
- }
- public static void Display2D(int[,] p)
- {
- for (int i = 0; i < p.GetLength(0); i++)
- {
- for (int j = 0; j < p.GetLength(1); j++)
- {
- Console.Write(p[i,j] + " ");
- }
- Console.WriteLine();
- }
- }
- public static List<string> StringLine(int[,] p)
- {
- List<string> lista = new List<string>();
- for (int i = 0; i < p.GetLength(0); i++)
- {
- string str = "";
- for (int j = 0; j < p.GetLength(1); j++)
- {
- str = str + p[i, j] + " "; //5 7
- }
- lista.Add(str);
- // Console.WriteLine();
- }
- return lista;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement