Vftfg
08.03.2023 22:44

Найдите значение переменной К в пайтоне


Найдите значение переменной К в пайтоне

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
inkara8
13.12.2020 12:28

using System;

internal class Program {

   private static void Main() {

       Console.WriteLine("Введите минимум для счетчика");

       var min = int.Parse(Console.ReadLine() ?? throw new ());

       Console.WriteLine("Введите максимум для счетчика");

       var max = int.Parse(Console.ReadLine() ?? throw new ());

       Console.WriteLine("Введите значение для счетчика");

       var v = int.Parse(Console.ReadLine() ?? throw new ());

       var counter = new Counter(max, min, v);

       Console.WriteLine("Введите + для увеличение и - для уменьшения, иное для выхода");

       do {

           var c = Console.ReadKey();

           if (c.KeyChar == '+') counter.Increase();

           else if (c.KeyChar == '-') counter.Decrease();

           else break;

           Console.WriteLine($" => {counter.Value}");

       } while (true);

       Console.ReadKey();

   }

}

public class Counter {

   public readonly int Maximum;

   public readonly int Minimum;

   public int Value { private set; get; }

   public Counter(int maximum, int minimum, int counter) {

       this.Maximum = maximum;

       this.Minimum = minimum;

       counter = Math.Min(this.Maximum, counter);

       counter = Math.Max(this.Minimum, counter);

       this.Value = counter;

   }

   private Counter() {

       this.Maximum = 10;

       this.Minimum = 0;

       this.Value = 5;

   }

   public void Increase() {

       var value = this.Value + 1;

       if (value > this.Maximum || value < this.Minimum)

           return;

       this.Value++;

   }

   public void Decrease() {

       var value = this.Value - 1;

       if (value > this.Maximum || value < this.Minimum)

           return;

       this.Value--;

   }

}

0,0(0 оценок)
Ответ:
dis8
17.11.2022 01:57
//Pascal ABC.NET v3.0 сборка 1111

Const
 n=5;

Var
 ma:array[1..n,1..n] of integer;
 i,j:integer;
begin
 writeln('Matrix reading...');
 for i:=1 to n do
  begin
   writeln;
    for j:=1 to n do
      readln(ma[i,j]);
  end;
 writeln('First matrix:');
 for i:=1 to n do
  begin
   writeln;
    for j:=1 to n do
     begin
      write(ma[i,j]:4);
      if (ma[i,j]<-8) or (ma[i,j]>6) then ma[i,j]:=sqr(ma[i,j]);
     end;
  end;
 writeln;
 writeln('Final matrix:');
 for i:=1 to n do
  begin
   writeln;
    for j:=1 to n do
     write(ma[i,j]:4);
  end;
end.

Пример ввода:
1
2
3
4
5

6
7
8
9
1

2
3
4
5
6

7
8
9
1
2

3
4
5
6
7
Пример вывода:
First matrix:
   1   2   3   4   5
   6   7   8   9   1
   2   3   4   5   6
   7   8   9   1   2
   3   4   5   6   7
Final matrix:
   1   2   3   4   5
   6  49  64  81   1
   2   3   4   5   6
  49  64  81   1   2
   3   4   5   6  49
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота