Skip to content

Instantly share code, notes, and snippets.

View Strelok78's full-sized avatar

Shota Strelok78

  • Saint-Petersburg, Russia
View GitHub Profile
@Strelok78
Strelok78 / Local max
Last active April 29, 2025 13:34
A one-dimensional array of integers of 30 elements is given. Finds all local maxima and outputs them. The program works with an array of any size.
using System.Collections;
using System.Diagnostics;
using System.Text;
namespace iJuniorPractice;
class Program
{
static void Main(string[] args)
{
@Strelok78
Strelok78 / Dynamic array
Last active May 16, 2023 16:52
The user enters the numbers, and the program remembers them. When user enters the sum command, the program outputs the sum of all the entered numbers. The program exits only if the user enters the exit command.
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
const string CommandSum = "sum";
const string CommandExit = "exit";
int[] ints = new int[0];
@Strelok78
Strelok78 / Subarray of repeating numbers
Last active May 17, 2023 12:07
Outputs to the console the array itself, the number that is repeated the most number of times in a row and the number of its repetitions. (An additional array is not created on purpose.)
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
int arraySize = 30;
int[] numbers = new int[arraySize];
int maxValue = 10;
int counter = 0;
@Strelok78
Strelok78 / Sorting numbers
Last active May 16, 2023 16:57
Outputs sorted numbers to the console, from the smallest to the largest. Array.Sort is not used.
using System.Runtime.CompilerServices;
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
int arraySize = 10;
int maxValue = 20;
@Strelok78
Strelok78 / Split method
Last active May 16, 2023 16:59
Using the String.Split() method, get an array of words that are separated by a space in the text and output an array, each word with a new line.
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
string text = "Using the String.Split() method, get an array of words that are " +
"separated by a space in the text and output an array, each word with a new line.";
string[] strings;
@Strelok78
Strelok78 / Shifting array values
Last active May 17, 2023 12:05
Shifts the number by the user-specified position value to the left using loops, without using other arrays.
namespace iJuniorRefactoring
{
internal class Program
{
static void Main(string[] args)
{
int[] numbers = { 1, 2, 3, 4, 5 };
int temp;
ShowArray(numbers);
@Strelok78
Strelok78 / Personnel accounting
Last active May 17, 2023 06:40
Filling in arrays of personal files, formatted output, search by last name and deleting personal files.
internal class Program
{
static void Main(string[] args)
{
const string CommandAddPerson = "1";
const string CommandShowData = "2";
const string CommandRemovePerson = "3";
const string CommandSearchPerson = "4";
const string CommandExit = "5";
@Strelok78
Strelok78 / Console UI Health or Mana bar
Last active May 17, 2023 06:42
Draws a certain bar in a certain position. It also accepts a certain shaded percentage.
internal class Program
{
static void Main(string[] args)
{
int maxValue = 10;
int value = 5;
int colorCode = 1;
char openSymbol = '[';
char closeSymbol = ']';
char parametrSymbol = ' ';
@Strelok78
Strelok78 / Read int (Try parse practice)
Last active May 17, 2023 06:45
Requests a number from the user and tries to convert it to the int type. If the conversion failed, the user is asked for the number again until it is entered correctly. After the input that was converted to a number, the number is returned.
internal class Program
{
static void Main(string[] args)
{
int number;
number = GetNumber();
Console.WriteLine(number);
}
static int GetNumber()
@Strelok78
Strelok78 / Console Game map
Last active May 17, 2023 06:48
A game map using a two-dimensional array. The user has the ability to move around the map and interact with the elements
internal class Program
{
static void Main(string[] args)
{
int startX = 1;
int startY = 1;
int[] position = new int[2];
bool isOpen = true;
string character = "$";
string freespace = " ";