예제 #1
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int index = 0;
            int count = 0;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                Write.Arrow();
                if (!int.TryParse(input, out number))
                {
                    continue;
                }

                if (number == index)
                {
                    count++;
                }

                index++;
            }

            Console.WriteLine(count);
        }
예제 #2
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int min = int.MaxValue;
            int max = int.MinValue;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }

                if (number > max)
                {
                    max = number;
                }
                if (number < min)
                {
                    min = number;
                }

                Write.Arrow();
            }

            Console.WriteLine($"min: {min}");
            Console.WriteLine($"min: {max}");
        }
예제 #3
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int lastNumber = new int();

            bool firstTime = true;

            bool startDescending = false;
            bool bitonic         = true;


            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }
                if (firstTime)
                {
                    lastNumber = number;
                    firstTime  = false;
                    Write.Arrow();
                    continue;
                }

                if (!bitonic)
                {
                    Write.Arrow();
                    continue;
                }

                if (lastNumber > number)
                {
                    startDescending = true;
                }

                if (lastNumber < number && startDescending)
                {
                    bitonic = false;
                }

                lastNumber = number;
                Write.Arrow();
            }

            if (bitonic)
            {
                Console.WriteLine("secventa este bitonica");
            }
            else
            {
                Console.WriteLine("secventa nu este bitonica");
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            string input;
            int    number     = new int();
            int    lastNumber = new int();

            bool firstTime = true;

            int descendingCount = 0;
            int first           = new int();


            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }
                if (firstTime)
                {
                    lastNumber = number;
                    first      = number;
                    firstTime  = false;
                    Write.Arrow();
                    continue;
                }

                if (lastNumber > number)
                {
                    descendingCount++;

                    if (first < number)
                    {
                        descendingCount += 2;
                    }
                }

                lastNumber = number;
                Write.Arrow();
            }

            if (descendingCount == 0)
            {
                Console.WriteLine("secventa este crescatoare");
            }
            else if (descendingCount == 1)
            {
                Console.WriteLine("secventa este crescatoare rotita");
            }
            else
            {
                Console.WriteLine("secventa nu este crescatoare rotita");
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            string input      = null;
            int    number     = new int();
            int    lastnumber = new int();

            bool ascending = true;
            bool firstTime = true;

            Write.EscMessage();

            //Write.Arrow();
            //number.GetInt();
            //lastnumber = number;

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }

                if (firstTime)
                {
                    lastnumber = number;
                    firstTime  = false;
                }

                if (number < lastnumber)
                {
                    ascending = false;
                }

                lastnumber = number;

                Write.Arrow();
            }

            if (ascending)
            {
                Console.WriteLine("Secventa este crescatoare");
            }
            else
            {
                Console.WriteLine("Secventa NU este crescatoare");
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int  lastNumber = new int();
            bool firstTime  = true;

            int count = 0;
            int max   = 0;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }
                if (firstTime)
                {
                    lastNumber = number;
                    firstTime  = false;
                    Write.Arrow();
                    continue;
                }

                if (lastNumber == number)
                {
                    count++;
                }
                else
                {
                    if (max < count)
                    {
                        max = count + 1;
                    }

                    count = 0;
                }

                lastNumber = number;
                Write.Arrow();
            }

            Console.WriteLine(max);
        }
예제 #7
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int sum = 0;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }

                sum += Reverse(number);

                Write.Arrow();
            }

            Console.WriteLine($"sum = {sum}");
        }
예제 #8
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            int count = 0;

            int lastNumber = new int();

            bool firstTime = true;

            bool crescator    = true;
            bool descrescator = true;
            bool strict       = true;

            Write.EscMessage();

            do
            {
                Write.Arrow();
                while (Methods.ReadOrStop(out input))
                {
                    if (!int.TryParse(input, out number))
                    {
                        continue;
                    }
                    if (firstTime)
                    {
                        lastNumber = number;
                        firstTime  = false;
                        Write.Arrow();
                        continue;
                    }

                    if (lastNumber > number)
                    {
                        crescator = false;
                    }
                    if (lastNumber < number)
                    {
                        descrescator = false;
                    }
                    if (lastNumber == number)
                    {
                        strict = false;
                    }

                    count++;
                    lastNumber = number;
                    Write.Arrow();
                }

                if (count >= 2)
                {
                    break;
                }

                Console.WriteLine();
                Console.WriteLine("introduceti cel putin 2 numere");
                Console.WriteLine();
            } while (count < 2);


            if (!crescator && !descrescator)
            {
                Console.WriteLine("secventa nu este monotona");
            }
            else
            {
                if (crescator)
                {
                    if (strict)
                    {
                        Console.WriteLine("secventa este strict crescatoare");
                    }
                    else
                    {
                        Console.WriteLine("secventa este crescatoare");
                    }
                }
                if (descrescator)
                {
                    if (strict)
                    {
                        Console.WriteLine("secventa este strict descrescatoare");
                    }
                    else
                    {
                        Console.WriteLine("secventa este descrescatoare");
                    }
                }
            }
        }
예제 #9
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();

            bool correct = true;

            int brackets = 0;

            int max = 0;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }
                if (number != 0 && number != 1)
                {
                    continue;
                }

                if (!correct)
                {
                    Write.Arrow();
                    continue;
                }

                if (number == 0)
                {
                    brackets++;
                }
                if (number == 1)
                {
                    brackets--;
                }

                if (brackets > max)
                {
                    max = brackets;
                }

                if (brackets < 0)
                {
                    correct = false;
                }

                Write.Arrow();
            }


            if (correct)
            {
                Console.WriteLine($"corect: {max}");
            }
            else
            {
                Console.WriteLine("incorect");
            }
        }
예제 #10
0
        static void Main(string[] args)
        {
            string input;
            int    number = new int();
            int    n1     = new int();
            int    n2     = new int();

            int first = new int();

            int inputs = 0;

            int changes = 0;

            Write.EscMessage();

            Write.Arrow();
            while (Methods.ReadOrStop(out input))
            {
                if (!int.TryParse(input, out number))
                {
                    continue;
                }
                if (inputs < 2)
                {
                    if (inputs == 0)
                    {
                        first = number;
                        n2    = number;
                    }
                    if (inputs == 1)
                    {
                        n1 = n2;
                        n2 = number;
                    }
                    inputs++;
                    Write.Arrow();
                    continue;
                }
                if (changes > 2)
                {
                    Write.Arrow();
                    continue;
                }

                if ((n1 > n2 && n2 < number) || (n1 < n2 && n2 > number))
                {
                    changes++;
                }
                if (changes == 2 && first > number)
                {
                    changes += 3;
                }

                n1 = n2;
                n2 = number;
                Write.Arrow();
            }

            if (changes > 2)
            {
                Console.WriteLine("secventa nu este bitonica rotita");
            }
            else
            {
                Console.WriteLine("secventa este bitonica rotita");
            }
        }