Compare commits
No commits in common. "f05125e298df2c1a0fda8e43c5c09979428d90b1" and "f7b11d94447c3425487126949ff4b9439da04c9b" have entirely different histories.
f05125e298
...
f7b11d9444
|
@ -107,6 +107,7 @@ public class Lab2 {
|
||||||
valueRepeats = true;
|
valueRepeats = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sum += tmpSmallest;
|
||||||
|
|
||||||
if (!valueRepeats) {
|
if (!valueRepeats) {
|
||||||
sum += tmpSmallest;
|
sum += tmpSmallest;
|
||||||
|
|
|
@ -1,65 +1,17 @@
|
||||||
package lab3;
|
package lab3;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Знайти найбільшу кількість речень заданого тексту, в яких є однакові слова.
|
* Знайти найбільшу кількість речень заданого тексту, в яких є однакові слова.
|
||||||
*/
|
*/
|
||||||
public class Variant0 {
|
public class Variant0 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("\\");
|
String textString = "A, a. B a. B a. B a. C.";
|
||||||
String textString = "Aa, a b. Bb a? B a! B a. Ccc.";
|
final String[] sentencesStrings = textString.split("\\. ?");
|
||||||
// final String[] sentencesStrings = textString.split("(?<=(\\.|!|\\?)) ");
|
|
||||||
// final String[] sentencesStrings = textString.split("(?<=[.!?]) ");
|
|
||||||
final String[] sentencesStrings = textString.split("[.!?] ?");
|
|
||||||
for (String sentencesString : sentencesStrings) {
|
for (String sentencesString : sentencesStrings) {
|
||||||
System.out.println("[" + sentencesString + "]");
|
System.out.println(sentencesString);
|
||||||
}
|
}
|
||||||
System.out.println("++++++++++++");
|
|
||||||
|
|
||||||
final String[][] wordsStringsBySentences = new String[sentencesStrings.length][];
|
|
||||||
for (int i = 0; i < sentencesStrings.length; i++) {
|
|
||||||
wordsStringsBySentences[i] = sentencesStrings[i].split(",? ");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String[] wordsStrings : wordsStringsBySentences) {
|
|
||||||
for (String wordsString : wordsStrings) {
|
|
||||||
System.out.print("[" + wordsString + "] - ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> originalWordsStrings = new HashSet();
|
|
||||||
for (String[] wordsStrings : wordsStringsBySentences) {
|
|
||||||
for (String wordsString : wordsStrings) {
|
|
||||||
originalWordsStrings.add(wordsString.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String[] originalWordsArray = originalWordsStrings.toArray(new String[0]);
|
|
||||||
|
|
||||||
System.out.println("++++++++++++");
|
|
||||||
for (Object originalWordsString : originalWordsStrings) {
|
|
||||||
System.out.println(originalWordsString);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] entersQuantitiesOriginalWordsInSentences = new int[originalWordsArray.length];
|
|
||||||
for (int i = 0; i < originalWordsArray.length; i++) {
|
|
||||||
String originalWord = originalWordsArray[i];
|
|
||||||
for (String[] words : wordsStringsBySentences) {
|
|
||||||
for (String word : words) {
|
|
||||||
if (originalWord.equalsIgnoreCase(word)) {
|
|
||||||
entersQuantitiesOriginalWordsInSentences[i]++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo show greatest value from entersQuantitiesOriginalWordsInSentences
|
|
||||||
|
|
||||||
// System.out.println(Arrays.toString(sentencesStrings));
|
// System.out.println(Arrays.toString(sentencesStrings));
|
||||||
System.out.println("++++++++++++");
|
System.out.println("++++++++++++");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
package lab4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* My class Furniture.
|
|
||||||
*/
|
|
||||||
public class Furniture {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private String material;
|
|
||||||
private int length;
|
|
||||||
private int height;
|
|
||||||
private int width;
|
|
||||||
private int price;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param material
|
|
||||||
* @param length
|
|
||||||
* @param height
|
|
||||||
* @param width
|
|
||||||
* @param price
|
|
||||||
*/
|
|
||||||
public Furniture(String material, int length, int height, int width, int price) {
|
|
||||||
this.material = material;
|
|
||||||
this.length = length;
|
|
||||||
this.height = height;
|
|
||||||
this.width = width;
|
|
||||||
this.price = price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrice() {
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public Furniture() {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
|
|
@ -1,22 +1,7 @@
|
||||||
package lab4;
|
package lab4;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
//todo equals+hashcode
|
//todo equals+hashcode
|
||||||
// todo JavaDoc
|
|
||||||
Furniture[] furnitureArray = {
|
|
||||||
new Furniture("A", 1, 1, 1, 1),
|
|
||||||
new Furniture("D", 1, 1, 1, 4),
|
|
||||||
new Furniture("B", 1, 2, 1, 1),
|
|
||||||
new Furniture("C", 1, 1, 3, 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
Arrays.sort(furnitureArray, (o1, o2) -> o1.getMaterial().compareTo(o2.getMaterial()));
|
|
||||||
// todo print
|
|
||||||
|
|
||||||
// todo check
|
|
||||||
Arrays.sort(furnitureArray, (o1, o2) -> Integer.compare(o2.getPrice(), o1.getPrice()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue