Advertisement
BojidarDosev

zadacha 4

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