Skip to content

Instantly share code, notes, and snippets.

View muromtsev's full-sized avatar
Hi

Ilya muromtsev

Hi
  • Russia Volgograd
View GitHub Profile
@muromtsev
muromtsev / sortingStudentsByGrades.cpp
Created March 1, 2024 17:13
Sorting students by grades
#include <iostream>
#include <string>
struct Students
{
std::string name;
int grade;
};
void sortNames(Students *students, int length)
@muromtsev
muromtsev / blackJack.cpp
Last active March 3, 2024 08:53
BlackJack
#include <iostream>
#include <array>
#include <cstring>
#include <cstdlib>
#include <ctime>
// перечисление для достоинств карт
enum CardRank
{
@muromtsev
muromtsev / calculator.cpp
Created March 3, 2024 08:53
Calculator (Pointers to functions)
#include <iostream>
int add(int x, int y){ return x + y; }
int multiply(int x, int y){ return x * y; }
int subtract(int x, int y){ return x - y; }
int divide(int x, int y){ return x / y; }
typedef int (*arithmeticFcn)(int, int);
struct arithmeticStruct
1.
https://github.com/alexey-goloburdin/typed-python-book
@muromtsev
muromtsev / quick_sort.py
Last active October 12, 2023 17:52
Quick sort
def quicksort(arr):
if len(arr) < 2:
return arr
else:
pivot = arr[0]
less = [i for i in arr[1:] if i < pivot]
greater = [i for i in arr[1:] if i > pivot]
return quicksort(less) + [pivot] + quicksort(greater)
@muromtsev
muromtsev / binary_search.py
Created October 12, 2023 17:52
binary_search
def binary_search(lst, item):
low = 0
high = len(lst) - 1
while low <= high:
mid = (low + high) // 2
guess = lst[mid]
if guess == item:
return mid
if guess > item:
@muromtsev
muromtsev / selection_sort.py
Created October 11, 2023 18:33
Selection sort
def findSmallest(arr):
smallest = arr[0]
smallest_idx = 0
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
smallest_idx = i
return smallest_idx