Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 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.  
  7. namespace ConsoleApplication3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Random rnd = new Random();
  14.  
  15. int[,] tab = new int[5, 4];
  16.  
  17. int x = 0;
  18. int y = 0;
  19. while (x < 5)
  20. {
  21. y = 0;
  22. while (y < 4)
  23. {
  24. if (y == 3)
  25. {
  26. tab[x, y] = ((tab[x, y - 3] + tab[x, y - 2]) * tab[x, y - 1]) / 2;
  27. }
  28. else
  29. {
  30. tab[x, y] = rnd.Next(1, 100);
  31. }
  32. y++;
  33. }
  34. x++;
  35. }
  36.  
  37. x = 0;
  38.  
  39. while (x < 5)
  40. {
  41. y = 0;
  42. while (y < 2)
  43. {
  44.  
  45. Console.Write(tab[x, y] + " ");
  46. y++;
  47.  
  48. }
  49. x++;
  50. Console.WriteLine();
  51. }
  52. Console.WriteLine();
  53. Console.WriteLine();
  54.  
  55. Console.Write("Podaj pole: ");
  56.  
  57. int zapytanie = Convert.ToInt32(Console.ReadLine());
  58.  
  59. x = 0;
  60. while (x < 5)
  61. {
  62. if (zapytanie < tab[x, 3])
  63. Console.WriteLine("Pole trapezu(" + tab[x, 0] + "," + tab[x, 1] + "," + tab[x, 2] + ") = " + tab[x, 3]);
  64. x++;
  65. }
  66. Console.ReadKey();
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement