Advertisement
BojidarDosev

zadacha 5*

Mar 1st, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 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 ConsoleApp2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double r,max;
  14.             int i, j,p,p1;
  15.             int[,] array = new int[10, 2];
  16.             for (i = 0; i < 10; i++)
  17.             {
  18.                 array[i, 0] = int.Parse(Console.ReadLine());
  19.                 array[i, 1] = int.Parse(Console.ReadLine());
  20.             }
  21.             //a
  22.             for ( i=0;i<10; i++)
  23.             {
  24.                 Console.WriteLine(array[i, 0] + " " + array[i, 1]);
  25.             }
  26.             Console.WriteLine();
  27.             //b
  28.             for (i = 0; i < 10; i++)
  29.             {
  30.                 Console.Write(array[i, 0] + " " + array[i, 1] + " " );
  31.                 if (array[i, 0] > 0 && array[i, 1] > 0) Console.WriteLine("kwadrant 1");
  32.                 if (array[i, 0] > 0 && array[i, 1] < 0) Console.WriteLine("kwadrant 4");
  33.                 if (array[i, 0] < 0 && array[i, 1] > 0) Console.WriteLine("kwadrant 2");
  34.                 if (array[i, 0] < 0 && array[i, 1] < 0) Console.WriteLine("kwadrant 3");
  35.  
  36.             }
  37.             //c
  38.             for (i = 0; i < 10; i++)
  39.             {
  40.                 Console.Write(array[i, 0] + " " + array[i, 1] + " ");
  41.                 r = Math.Sqrt(Math.Pow(array[i, 0], 2) + Math.Pow(array[i, 1], 2));
  42.                 Console.WriteLine("razstoqnieto = " + r);
  43.             }
  44.             //d
  45.             max = 0;p = 0;
  46.             for (i = 0; i < 10; i++)
  47.             {
  48.                 r = Math.Sqrt(Math.Pow(array[i, 0], 2) + Math.Pow(array[i, 1], 2));
  49.                 if (max < r)
  50.                 {
  51.                     max = r;
  52.                     p = i;
  53.                 }
  54.  
  55.             }
  56.             Console.WriteLine("max razst. = " + max + " na tochka " + p);
  57.             //e
  58.             max = 0; p = 0;p1 = 0;
  59.             for (i = 0; i < 9; i++)
  60.             {
  61.                 for (j = i + 1; j < 10; j++)
  62.                 {
  63.                     r = Math.Sqrt(Math.Pow(array[i, 0] - array[j, 0], 2) - Math.Pow(array[i, 1] - array[j, 1], 2));
  64.                     if (max < r)
  65.                     {
  66.                         p1 = j;
  67.                         p = i;
  68.                     }
  69.                 }
  70.             }
  71.             Console.WriteLine("nai otdalecheni tochki: " + p + " " + p1);
  72.         }
  73.     }
  74. }
  75. /*
  76. 3
  77. 4
  78. -1
  79. 4
  80. -5
  81. -4
  82. 7
  83. -1
  84. 10
  85. 10
  86. -5
  87. -2
  88. -10
  89. -10
  90. 7
  91. -4
  92. 9
  93. 9
  94. 2
  95. 3
  96. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement