Advertisement
BojidarDosev

зад 4,5,6 стр 358-359 уч.

Feb 21st, 2021
1,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp777
  4. {
  5.     class Program
  6.     {
  7.        
  8.         static int[] array = new int[5] { 3, 3, 3, 3, 3 };
  9.         static int Br (int a)
  10.         {
  11.             int br = 0;
  12.             for(int i = 0; i<5; i++)
  13.             {
  14.                 if (a == array[i])
  15.                     br++;
  16.             }
  17.             return br;    
  18.         }
  19.         static string Golqm(int p)
  20.         {
  21.             string s = "no";
  22.             if (p == 0 && array[p] > array[p + 1])
  23.                 s = "yes";
  24.             else
  25.             if (p == array.Length - 1 && array[p] > array[p - 1])
  26.                 s = "yes";
  27.             else
  28.             if (p>0 && array[p] > array[p - 1] && array[p] > array[p + 1] )
  29.                 s = "yes";
  30.             return s;
  31.         }
  32.         static int First()
  33.         {
  34.             int a = -1;
  35.             int flag = 0;
  36.             if (array[0] > array[1])
  37.                 a = 0;
  38.             else
  39.                 for(int i = 1; i < 4; i++)
  40.                 {
  41.                     if(array[i] > array[i-1] && array[i] > array[i + 1])
  42.                     {
  43.                         a = i;
  44.                         flag = 1;
  45.                         break;
  46.                     }
  47.                    
  48.                 }
  49.            if(flag == 0 && array[4]>array[3])
  50.             {
  51.                 a = 4;
  52.             }
  53.             return a;
  54.         }
  55.         static void Main(string[] args)
  56.    
  57.         {
  58.             int a = int.Parse(Console.ReadLine());
  59.             Console.WriteLine("broqt = " + Br(a));
  60.             int poz = int.Parse(Console.ReadLine());
  61.             Console.WriteLine("po golqmo li e chisloto poz - " + Golqm(poz));
  62.             Console.WriteLine("purviq element ima poziciq : " + First());
  63.         }
  64.     }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement