|
|
вернуться в форумHelp in Java 1.7 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Scanner; public class Test { public static void main(String[] args) throws IOException { new Test().solve(); } private static Scanner s = new Scanner(System.in); static int n = 0; void solve() throws IOException { String input = null; String[] strArray = new String[30]; while (true) { input = getString(); if (input.equals("#")) { break; } else { saveItToArray(strArray, input); } } checkOutIdentical(strArray); System.out.println(n - 1); } private static String getString() throws IOException {
String input; input = s.nextLine(); return (input); } void saveItToArray(String[] strArray, String input) { boolean isDash = false; for (int i = 0; i < input.length(); i++) { if (input.charAt(i) == '-') { strArray[n++] = input.substring(0, i); strArray[n++] = input.substring(i + 1, input.length()); isDash = true; break; } else { isDash = false; } } if (!isDash) { strArray[n++] = input; } } void checkOutIdentical(String[] strArray) { int count = 0; count = n; for (int i = 1; i < count; i++) { for (int j = i - 1; j >= 0; j--) { if (!strArray[i].equals(" ") && !strArray[j].equals(" ") && strArray[i].equals(strArray[j])) { strArray[i] = " "; n--; } } } } } |
|
|