М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
biyubiyu
biyubiyu
06.04.2022 19:05 •  Информатика

Вкомнате веселились 1426 мух. петр петрович открыл форточку и, размахивая полотенцем, выгнал из комнаты 226 мух. но, прежде чем он успел закрыть форточку, 214 мух вернулись обратно. сколько мух теперь веселится в комнате?

👇
Ответ:
Ksyusha20
Ksyusha20
06.04.2022
1414 мух осталось в комнате
4,7(22 оценок)
Ответ:
Cronus1Oleg
Cronus1Oleg
06.04.2022
1426-226=1200      1200+214=1414
4,4(52 оценок)
Открыть все ответы
Ответ:
lelchist
lelchist
06.04.2022

using System;

namespace ConsoleApp4

{

   class Program

   {

       static void Main(string[] args)

       {

           Console.WriteLine("Введите n: ");

           double equal1 = 0;

           double equal2 = 0;

           int i1 = 1;

           int n = Int32.Parse(Console.ReadLine());

           for(int i = 1; i <= n; i++) {

               equal1 += Math.Pow(-1, i);

               Console.Write(Math.Pow(-1, i) + " ");

           }

           Console.Write("equal1 = ");

           Console.WriteLine(equal1);

           while (i1 <= n) {

               equal2 += Math.Pow(-1, i1);

               Console.Write(Math.Pow(-1, i1) + " ");

               i1++;

           }

           Console.Write("equal2 = ");

           Console.WriteLine(equal2);

       }

   }

}

4,6(9 оценок)
Ответ:
erzhankenzhekan
erzhankenzhekan
06.04.2022

using System;

using System.Collections.Generic;

using System.Text;

namespace MyQueue

{

   public class QueueException : Exception { }

   public class Queue <T>

   {

       private const int _basicCapacity = 8;

       private int _capacity;

       private int _count;

       private T[] _items;

       private int _begin;

       private int _end;

       

       public int Capacity

       {

           get => _capacity;

           protected set

           {

               int newCapacity = value;

               T[] newItems = new T[newCapacity];

               Count = Math.Min(Count, Capacity);

               for (int i = 0; i < Count; i++)

               {  

                   newItems[i] = _items[(_begin + i) % Capacity];

               }

               _begin = 0;

               _end = Count;

               _items = newItems;

               _capacity = newCapacity;

           }

       }

       

       public int Count

       {

           get => _count;

           protected set => _count = value;

       }

       

       public Queue()

       {

           Capacity = _basicCapacity;

           Count = 0;

           _begin = 0;

           _end = 0;

           _items = new T[Capacity];

       }

       

       public void Enqueue(T item)

       {

           if (Count == Capacity)

           {

               Capacity *= 2;

           }

           Count++;

           _items[_end] = item;

           _end = (_end+1) % Capacity;

       }

       

       public bool IsEmpty()

       {

           return Count == 0;

       }

       

       public T Dequeue()

       {

           if (IsEmpty())

           {

               throw new QueueException();

           }

           T item = _items[_begin];

           _begin = (_begin+1) % Capacity;

           Count--;

           if (Count * 4 < Capacity)

           {

               int newCapacity = Math.Max(Capacity / 4, _basicCapacity);

               if (newCapacity < Capacity)

               {

                   Capacity = newCapacity;

               }

           }

           return item;

       }

       

       public T Peek()

       {

           if (IsEmpty())

           {

               throw new QueueException();

           }

           return _items[_begin];

       }

       

       public override string ToString()

       {

           StringBuilder sb = new StringBuilder();

           for(int i = 0; i < Count; i++){

               if (i > 0)

               {

                   sb.Append(" ");

               }

               sb.Append(_items[(_begin+i) % Capacity].ToString());

           }

           return sb.ToString();

       }

       

       public void Clear()

       {

           Count = 0;

           _begin = 0;

           _end = 0;

           if (Capacity > _basicCapacity)

           {

               Capacity = _basicCapacity;

           }

       }

   }

   

   class Program

   {

       public static void Main (string[] args)

       {

           Queue <double> q = new Queue <double>();

           for(int i = 0; i < 20; i++){

               q.Enqueue(i);

           }

           Console.WriteLine("0-19: \"{0}\"", q.ToString());

           for(int i = 0; i < 10; i++)

           {

               Console.WriteLine("Peek: {0}", q.Peek());

               Console.WriteLine("Dequeue: {0}", q.Dequeue());

           }

           Console.WriteLine("10-19: \"{0}\"", q.ToString());

           q.Clear();

           Console.WriteLine("Empty queue representation: \"{0}\"", q.ToString());

           Console.WriteLine("Queue is empty? {0}", q.IsEmpty());

       }

   }

}

Объяснение:

Реализация циклической очереди с примерами использования.

Тот же самый код тут: onlinegdb.com/SkyJfEvnS

4,7(89 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ