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--;
}
}
naromanova
07.12.2021
1) var x:integer; begin read (x); if (x=12) or (x=1) or (x=2) then writeln ('Зима'); if (x=3) or (x=4) or (x=5) then writeln ('Весна'); if (x=6) or (x=7) or (x=8) then writeln ('Лето'); if (x=9) or (x=10) or (x=11) then writeln ('Осень'); end. 2) var K,a:integer; begin readln(K); a:=K mod 10; if (K=11) or(K=12) or (K=13) or (K=14) then writeln ('У меня ',K,' друзей') else begin if (a=1) then writeln ('У меня ',K,' друг'); if (a=0) or ((a>=5) and (a<=9)) then writeln ('У меня ',K,' друзей'); if (a>=2) and (a<=4) then writeln ('У меня ',K,' друга'); end; end.
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--;
}
}