Skip to content

Instantly share code, notes, and snippets.

View uladzislau-slk's full-sized avatar
👾
So complicated, so simple.

Uladzislau S. uladzislau-slk

👾
So complicated, so simple.
View GitHub Profile
@uladzislau-slk
uladzislau-slk / BubbleSort.java
Created October 17, 2018 12:47
Simple Bubble Sort
public class BubbleSort {
public static void main(String[] args) {
int nums[] = {99,-10,10012,18,-978,5623,463,-9,287,49};
int size = 10;
int buf;
System.out.print("Исходный массив: ");
for (int i = 0; i < size;i++) System.out.print(" " + nums[i]);
for (int j = 1; j < size ;j++) {
@uladzislau-slk
uladzislau-slk / BubbleSortKt.kt
Created October 17, 2018 12:49
Trying Kotlin
fun main(args: Array<String>) {
val nums: IntArray = intArrayOf(99, -10,100123,18,-978,5623,463,-9,287,49)
var size = 10
println("Исходный массив: ")
for (i in nums) print(" $i")
while (size > 0) {
(0 until size-1).forEach { i ->
if (nums[i] > nums[i+1]) {
var buf = nums[i]
public class ShakerSort {
public static void main(String[] args) {
int num[] = {123, -14, 324, -98, 101023, 0, -944, 708};
int buf;
System.out.println("Исходный массив: ");
for (int i = 0; i < num.length; i++) System.out.print(" " + num[i]);
for (int c = 1; c < num.length; c++) {
for (int p = 0; p < num.length - 1; p++) {
if (num[p] > num[p+1]) {
public class OddEvenSort {
public static void main(String[] args) {
int num[] = new int[10];
int min = -10000;
int max = 10000;
int buf;
for (int i = 0; i < num.length; i++) {
num[i] = (int) (Math.random() * (max - min)) + min;
}
@uladzislau-slk
uladzislau-slk / Palindrome.java
Created October 29, 2018 05:53
Is the string palindrome?
public class Palindrome {
public static void main(String[] args) {
isPalindrome("Madam, I'm Adam!");
}
/*public static boolean isPalindrome(String text) {
text = text.toLowerCase().replaceAll("[^a-zA-Z0-9]", "");
String sb = new StringBuilder(text).reverse().toString();
System.out.println(text);
return sb.equalsIgnoreCase(text);