Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace ConsoleApp2
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Manager();
  15. }
  16.  
  17. public static void Manager()
  18. {
  19. int[,] p = Create2D(60, 60);
  20.  
  21. Display2D(p);
  22.  
  23. var lista = StringLine(p);
  24.  
  25. File.WriteAllLines(@"C:\Users\pclab\Desktop\numera.txt",lista);
  26.  
  27. }
  28.  
  29.  
  30.  
  31.  
  32. public static int[,] Create2D (int x, int y)
  33. {
  34. Random tixaios = new Random();
  35. int[,] p = new int[x, y];
  36.  
  37. for (int i = 0; i < p.GetLength(0); i++)
  38. {
  39. for (int j = 0; j < p.GetLength(1); j++)
  40. {
  41. p[i, j] = tixaios.Next(0, 10);
  42. }
  43. }
  44.  
  45. return p;
  46. }
  47.  
  48. public static void Display2D(int[,] p)
  49. {
  50. for (int i = 0; i < p.GetLength(0); i++)
  51. {
  52. for (int j = 0; j < p.GetLength(1); j++)
  53. {
  54. Console.Write(p[i,j] + " ");
  55. }
  56. Console.WriteLine();
  57. }
  58.  
  59. }
  60.  
  61. public static List<string> StringLine(int[,] p)
  62. {
  63. List<string> lista = new List<string>();
  64. for (int i = 0; i < p.GetLength(0); i++)
  65. {
  66. string str = "";
  67. for (int j = 0; j < p.GetLength(1); j++)
  68. {
  69. str = str + p[i, j] + " "; //5 7
  70.  
  71. }
  72. lista.Add(str);
  73. // Console.WriteLine();
  74. }
  75. return lista;
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement