Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 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. for (int x = 0; x < 5; x++)
  18. {
  19.  
  20. for (int y = 0; y < 4; y++)
  21. {
  22. if (y == 3)
  23. {
  24. tab[x, y] = ((tab[x, y - 3] + tab[x, y - 2]) * tab[x, y - 1]) / 2;
  25. }
  26. else
  27. {
  28. tab[x, y] = rnd.Next(1, 100);
  29. }
  30. }
  31. }
  32.  
  33. for (int x = 0; x < 5; x++)
  34. {
  35.  
  36. for (int y = 0; y < 2; y++)
  37. {
  38.  
  39. Console.Write(tab[x, y] + " ");
  40.  
  41. }
  42. Console.WriteLine();
  43. }
  44. Console.WriteLine();
  45. Console.WriteLine();
  46.  
  47. Console.Write("Podaj pole: ");
  48.  
  49. int zapytanie = Convert.ToInt32(Console.ReadLine());
  50.  
  51.  
  52. for (int x = 0; x < 5; x++)
  53. {
  54. if (zapytanie < tab[x, 3])
  55. Console.WriteLine("Pole trapezu(" + tab[x, 0] + "," + tab[x, 1] + "," + tab[x, 2] + ") = " + tab[x, 3]);
  56.  
  57. }
  58. Console.ReadKey();
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement