using System;
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
int[,] arrayA = new int[3, 4]
{
{5, 5, 50, 5},
{5, 5, 5, 5},
{5, 5, 5, 2},
};
int[,] arrayB = new int[4, 2]
{
{5, 5},
{5, 1},
{15, 5},
{5, 1},
};
Console.WriteLine("Array A:");
Print(arrayA);
Console.WriteLine();
Console.WriteLine("Array B:");
Print(arrayB);
Console.WriteLine();
Console.WriteLine("Array A, first min value position:");
var (yMinA, xMinA) = FindFirstMinValuePosition(arrayA);
Print(xMinA, yMinA);
Console.WriteLine();
Console.WriteLine("Array B, first min value position:");
var (yMinB, xMinB) = FindFirstMinValuePosition(arrayB);
Print(xMinB, yMinB);
Console.WriteLine();
Console.WriteLine("Array A, first max value position:");
var (yMaxA, xMaxA) = FindFirstMaxValuePosition(arrayA);
Print(xMaxA, yMaxA);
Console.WriteLine();
Console.WriteLine("Array B, first max value position:");
var (yMaxB, xMaxB) = FindFirstMaxValuePosition(arrayB);
Print(xMaxB, yMaxB);
Swap(arrayA, arrayB, yMinA, xMinA, yMinB, xMinB);
Swap(arrayA, arrayB, yMaxA, xMaxA, yMaxB, xMaxB);
Console.WriteLine("----");
Console.WriteLine();
Console.WriteLine("Array A after two swaps:");
Print(arrayA);
Console.WriteLine();
Console.WriteLine("Array B after two swaps:");
Print(arrayB);
Console.WriteLine();
}
private static void Swap(int[,] arrayA, int[,] arrayB, int yA, int xA, int yB, int xB)
{
int tempB = arrayB[yB, xB];
arrayB[yB, xB] = arrayA[yA, xA];
arrayA[yA, xA] = tempB;
}
private static (int y, int x) FindFirstMinValuePosition(int[,] array)
{
if (array is null) throw new ArgumentNullException(nameof(array));
int y = array.GetLength(0);
int x = array.GetLength(1);
if (y == 0) throw new InvalidOperationException(
"The dimension of the array along the Y axis is zero.");
if (x == 0) throw new InvalidOperationException(
"The dimension of the array along the X axis is zero.");
int yResult = 0;
int xResult = 0;
int minValue = array[0, 0];
for (int yIndex = 0; yIndex < y; yIndex++)
{
for (int xIndex = 0; xIndex < x; xIndex++)
{
if (minValue > array[yIndex, xIndex])
{
yResult = yIndex;
xResult = xIndex;
minValue = array[yIndex, xIndex];
}
}
}
return (yResult, xResult);
}
private static (int y, int x) FindFirstMaxValuePosition(int[,] array)
{
if (array is null) throw new ArgumentNullException(nameof(array));
int y = array.GetLength(0);
int x = array.GetLength(1);
if (y == 0) throw new InvalidOperationException(
"The dimension of the array along the Y axis is zero.");
if (x == 0) throw new InvalidOperationException(
"The dimension of the array along the X axis is zero.");
int yResult = 0;
int xResult = 0;
int maxValue = array[0, 0];
for (int yIndex = 0; yIndex < y; yIndex++)
{
for (int xIndex = 0; xIndex < x; xIndex++)
{
if (maxValue < array[yIndex, xIndex])
{
yResult = yIndex;
xResult = xIndex;
maxValue = array[yIndex, xIndex];
}
}
}
return (yResult, xResult);
}
private static void Print(int x, int y)
{
Console.WriteLine($"x: {x}, y: {y}");
}
private static void Print(int[,] array)
{
int x = array.GetLength(0);
int y = array.GetLength(1);
for (int xIndex = 0; xIndex < x; xIndex++)
{
for (int yIndex = 0; yIndex < y; yIndex++)
{
Console.Write($"{array[xIndex, yIndex]}, ");
}
Console.WriteLine();
}
}
}
}
Array A:
5, 5, 50, 5,
5, 5, 5, 5,
5, 5, 5, 2,
Array B:
5, 5,
5, 1,
15, 5,
5, 1,
Array A, first min value position:
x: 3, y: 2
Array B, first min value position:
x: 1, y: 1
Array A, first max value position:
x: 2, y: 0
Array B, first max value position:
x: 0, y: 2
----
Array A after two swaps:
5, 5, 15, 5,
5, 5, 5, 5,
5, 5, 5, 1,
Array B after two swaps:
5, 5,
5, 2,
50, 5,
5, 1,
import hashlib
from random import randint
ALGS = ('sha3_512', 'sha384', 'md5', 'shake_128', 'sha256', 'sha3_256', 'sha3_224', 'sha512', 'blake2s', 'sha3_384', 'sha224', 'shake_256', 'blake2b', 'sha1')
first = 1
last = 999999
def prepare_target(target):
if not isinstance(target, bytearray):
if not isinstance(target, str):
target = str(target)
target = target.encode()
return target
def calc_hash(alg, target):
target = prepare_target(target)
if alg in ALGS:
command = f'hashlib.{alg}({target})'
try:
return eval(command).hexdigest()
except TypeError:
pass
def create_test_target(target_hash):
if target_hash is not None:
return '1'*len(target_hash)
def detect_hash_alg(target_hash):
result_algs = []
for alg in ALGS:
test_target = create_test_target(target_hash)
my_hash = calc_hash(alg, test_target)
if my_hash is not None:
lenght = len(my_hash)
if lenght == len(target_hash):
result_algs.append(alg)
return result_algs
def find_target(target_hash):
stop = False
algs = detect_hash_alg(target_hash)
print(f'подходящие алгоритмы: {algs}')
for i in range(first, last+1):
for alg in algs:
first_hash = calc_hash(alg, i)
if first_hash == target_hash:
print(f'founded\t{i} {alg}')
stop = True
break
if stop:
break
if not stop:
print(f'for {target_hash} not found')
if __name__ == '__main__':
target_hash = '127b1f0d6253fdfe78d806497217f2454a30e124d1f655b6c2a8c68f6dc7a7061993557b50252f253220a3a059142290cd0c2c467c0ee5bfbbd6a8a538c5d040'
test = randint(first, last+1)
alg = 'sha256'
test_hash = calc_hash(alg, test)
print(test_hash)
print(f'target \t{test} {alg}')
print('тестовый поиск:')
find_target(test_hash)
print('боевой поиск:')
find_target(target_hash)
double a, b, y = 0, p = 1, s = 0;
for (double x = 0.5; x <= 4; x += 0.5)
{
a = ((x * x) + 1) / x;
b = (Math.Pow(x, 3) + 2) / 4;
for (int n = 1; n <= 10; n++)
{
p *= (1 + (Math.Pow(x, n) / (n + 1)));
s += (Math.Pow(x, n) / n);
}
y = (a * p) + (b * s);
Console.WriteLine(y);
}