Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication10
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.WriteLine("Podaj ilosc wierszy");
  13. int i = Convert.ToInt32(Console.ReadLine());
  14. Console.WriteLine("Podaj ilosc kolumn");
  15. int j = Convert.ToInt32(Console.ReadLine());
  16. double[,] tab = new double[i, j];
  17. wczytaj(ref tab);
  18. wyswietl(tab);
  19. Console.WriteLine("Ktory wiersz chcesz zamienic");
  20. int o = Convert.ToInt32(Console.ReadLine());
  21. Console.WriteLine("... a z ktorym?");
  22. int p = Convert.ToInt32(Console.ReadLine());
  23. double[,]Y = new double[p,j];
  24. zamiana(tab, Y, o,p);
  25. wyswietl(tab);
  26. Console.ReadKey();
  27.  
  28. }
  29.  
  30. static void zamiana(double[,] tab, double[,] Y, int o, int p)
  31. {
  32. for (int i = 0; i < tab.GetLength(0); i++)
  33. {
  34.  
  35. for (int j = 0; j < tab.GetLength(1); j++)
  36. {
  37. Y[p, j] = tab[o, j];
  38. }
  39. }
  40. }
  41.  
  42.  
  43. static void wczytaj(ref double[,] tab)
  44. {
  45. Random obiekt = new Random();
  46. for (int i = 0; i < tab.GetLength(0); i++)
  47. {
  48.  
  49. for (int j = 0; j < tab.GetLength(1); j++)
  50. {
  51. tab[i, j] = obiekt.Next(0, 5);
  52. }
  53. }
  54. }
  55.  
  56.  
  57. static void wyswietl(double[,] tab)
  58. {
  59.  
  60. for (int i = 0; i < tab.GetLength(0); i++)
  61. {
  62. for (int j = 0; j < tab.GetLength(1); j++)
  63.  
  64. Console.Write(" {0} ", tab[i, j]);
  65. Console.Write("\n");
  66.  
  67. }
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement