This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |